2005 IR Help Posted August 27, 2006 Share Posted August 27, 2006 By: Stephan Portmann - spor afterReportInit() is not called in Scriptlet 2004-07-30 06:03 I wrote my own Scriptlet but the method afterReportInit() nor any other method gets called. I see that my scriptlet is instantiated...but no methods are called after words. thank you for any help. ******************************** import dori.jasper.engine.*; import java.awt.*; import java.awt.image.*; import java.sql.Connection; import java.sql.SQLException; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot3D; import org.jfree.data.CategoryDataset; import org.jfree.data.DatasetUtilities; import org.jfree.data.DefaultCategoryDataset; import org.jfree.data.JDBCCategoryDataset; import org.jfree.data.JDBCPieDataset; import org.jfree.data.PieDataset; public class ChartScriptlet extends JRDefaultScriptlet { private Connection _connection; public ChartScriptlet() { _connection = LoginServlet._connection; } public void afterReportInit() throws JRScriptletException { JDBCPieDataset pieDataSet = new JDBCPieDataset(_connection); try { pieDataSet.executeQuery("select * from pie_test"); } catch (SQLException sqlEx) { sqlEx.printStackTrace(); } JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", pieDataSet, true, true, false); BufferedImage image = chart.createBufferedImage(400, 400); this.setVariableValue("ChartImage", image); } } By: Mykel Alvis - evilarchitect RE: afterReportInit() is not called in Scriptlet 2004-07-30 07:46 1. Where does LoginServlet._connection come from? More specifically, where's the import for LoginServlet? Sounds likely that the class didn't compile. I use afterReportInit() extensively for exactly this purpose and it works flawlessly. By: Adrian - preziosoadrian RE: afterReportInit() is not called in Scriptlet 2004-11-06 14:50 I am experiencing the exact same problem. I am using the jfreechart sample that comes with jasper reports. My servlet exports the report to an html file with no errors, but the afterReportInit() method of JFreeChartScriplet does not get called. To be sure, I overrode all methods of JRDefaultScriplet in JFreeChartScriplet and added debug statements in them to tell me when they were entered. I do not see any of the debug messages except the one in the JFreeChartScriplet constructor. Very weird. Any suggestions? I'm really stuck. Thanks, Adrian Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now