sergeleo Posted September 4, 2009 Share Posted September 4, 2009 I have Crosstab report based on JRDataSource implementation. And when I was trying to put Crosstab into Details section, my report was always producing blank pages with no data... When I moved Crosstab into Summary section, my report comes out just fine, filled with data.Based on logs my JRDataSource implementation always been called from Details and from Summary. But only when my Crosstab in Summary section, my report renders data.I was looking through the forum and also I was googling for samples with implementation of the JRDataSource and Crossdab and so far I was able to find only few examples where Crosstab resides in Summary section. I wasn't able to find any example with JRDataSource and Crosstab in Detail section. So, is there any paerticular reason why it's not working? I'd like to take advantages of Page Headers and Footers in my report, but I can't unless I'll move my crosstab out of Summary...Please share your experience! Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Anyone??? I need help with this! Link to comment Share on other sites More sharing options...
lucianc Posted September 10, 2009 Share Posted September 10, 2009 See this FAQ.HTH,Lucian Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Lucian,I've seen this FAQ. This is not exactly that I want. I would like to have my JRDataSource driven Crosstab in Detail section instead of Summary... Is it posible or not? So far I haven't succeed. Link to comment Share on other sites More sharing options...
lucianc Posted September 10, 2009 Share Posted September 10, 2009 It's possible, you'll have to use a subdataset.Regards,Lucian Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Yes, I'm using subdataset... And I'm getting 3 blank pages. I can see vertical lines for each row at the far right side of the page, but there is no data... Log4j shows that my JRDataSource implementation been called for each element... So, I'm pretty sure that report is filled with data. But PDF, CVS, XLS exporters return blank pages.... Link to comment Share on other sites More sharing options...
lucianc Posted September 10, 2009 Share Posted September 10, 2009 Unless you post a sample report, I can't know why it doesn't work.If you want to see a working report with a crosstab in the detail band, check out demo/samples/crosstabs/ShipmentReport.jrxml and ProductsReport.jrxml. Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Thanks! I used ShipmentReport.jrxml and ProductsReport.jrxml as base for my prototype. But, they are based on SQL statement, not JRDataSource... So, I used this resource instead to get my report works http://broschb.blogspot.com/2008/05/dynamic-jasper-report-using-crosstabs.html Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Lucian, Please see JRXML and PDF attached. Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Same report, but Crosstab in Summary. Link to comment Share on other sites More sharing options...
lucianc Posted September 10, 2009 Share Posted September 10, 2009 If you use a subdataset for the crosstab, you need to pass in some data. If the subdataset does not have a query, you'll need to pass a data source, as belowRegards,LucianCode:<datasetrun subDataset=".."> <datasourceexpression>..this is the data that I want the subdataset to iterate on..</datasourceexpression></datasetrun>Post Edited by lucianc at 09/10/2009 16:58 Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 I made suggested change and now I have 15 blank pages /tools/fckeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif ((net.sf.jasperreports.engine.data.JRBeanCollectionDataSource)$P{REPORT_DATA_SOURCE}).cloneDataSource()Regards, SergePost Edited by sergeleo at 09/10/2009 07:01 PM Link to comment Share on other sites More sharing options...
sergeleo Posted September 10, 2009 Author Share Posted September 10, 2009 Lucian,How I can enable debugging for Jasper Reports?Regards, Serge Link to comment Share on other sites More sharing options...
lucianc Posted September 11, 2009 Share Posted September 11, 2009 sergeleoWrote: I made suggested change and now I have 15 blank pages /tools/fckeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif ((net.sf.jasperreports.engine.data.JRBeanCollectionDataSource)$P{REPORT_DATA_SOURCE}).cloneDataSource() Doing this doesn't make sense.Let's say the report data source returns 20 records. Then the detail band will be rendered 20 times. Each detail band will contain a crosstab which will display the same data set. So you'd end up with 20 identical crosstabs.Having a crosstab in the detail band only makes sense if the data source used for the crosstab (via the subdataset) is different for each record in the report data source.Why the crosstabs are empty I can't tell without seeing the data in your data source.Regards,Lucian Link to comment Share on other sites More sharing options...
lucianc Posted September 11, 2009 Share Posted September 11, 2009 sergeleoWrote: How I can enable debugging for Jasper Reports? What kind of debugging are you talkin about?If you want debug logging, JR uses Commons Logging, so it depends on the logging library that you use. For log4j for instance you would need to add log4j.logger.net.sf.jasperreports=debug to log4j.properties. Note though that JR does not (yet) feature thorough debug logging.If you want to do step-by-step debugging, download the JR sources and use any Java IDE to run your app in debug mode.Regards,Lucian Link to comment Share on other sites More sharing options...
sergeleo Posted September 11, 2009 Author Share Posted September 11, 2009 Lucian,Thank you!!! I'll set debug for Jasper in my Log4j. I'm trying something else for my Crosstab /tools/fckeditor/editor/images/smiley/msn/shades_smile.gif. I'll keep you posted /tools/fckeditor/editor/images/smiley/msn/thumbs_up.gifRegards, Serge Link to comment Share on other sites More sharing options...
sergeleo Posted September 14, 2009 Author Share Posted September 14, 2009 All,I finally resolved my issue with placing Crosstab into Detail section. Maybe my workaround can go to FAQ ot Exmaples... I switched my code to use JasperFillManager.fillReport(JasperReport jasperReport, Map parameters ) method. I'm not passing DataSource through the method parameter. I'm passing my implementation of JRDataSource as a parameter JRParameter.REPORT_DATA_SOURCE. Also I created custom parameter "DynamicDataSource" and I'm passing same JRDataSource there. Inside of my template I defined subDataset and parameter for DynamicDataSource defined by class="net.sf.jasperreports.engine.JRDataSource" My crosstab placed into Detail section and datasetRun refering to pre-defined subDataset with dataSourceExpression referring to custom parameter "DynamicDataSource"So, now my reports displays data in Detail section, and I can get advantage of use pageHeader, pageFooter and all other sections. Regards, SergeCode: protected JasperPrint fillJasperTemplate(JasperReport jasperReport, JRDataSource dataSource) throws JRException { // Preparing parameters // Setting up virtualizer to have only 2 pages in memory and // rest on file system JRFileVirtualizer virtualizer = new JRFileVirtualizer(2, System .getProperty("java.io.tmpdir")); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); parameters.put(JRParameter.REPORT_DATA_SOURCE, dataSource); parameters.put("DynamicDataSource", dataSource); return JasperFillManager.fillReport(jasperReport, parameters); } 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