Jump to content
We've recently updated our Privacy Statement, available here ×

lshannon

Members
  • Posts

    182
  • Joined

  • Last visited

lshannon's Achievements

Collaborator

Collaborator (7/14)

  • Conversation Starter Rare
  • First Post Rare
  • Collaborator Rare
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. IntroductionA common request is how to build reports in runtime on JasperReports Server. Luckily thanks to the flexibility of JasperReports this can easily be achieved. There are some small limitations, which we will review, however for the most part this is an easy and effective technique to give you very advanced functionality in the server. Programatically Creating ReportsThere are two ways the report can be created when using the API. A JasperDesign Object or a JasperReport. Whats the difference? JasperDesign represents the report design in a "editable" meaning there are a lot of setters available to modify the stateJasperReport also represents the report design, however it has been compiled and validated and is ready use with the JasperFillManager to create a JasperPrint object. The JasperReport object has less setters available making it more difficult to change its state after it has been created. This is basically the final version of the report design before you begin the process of running it against data to get an output for a clientA Word On JasperPrint ObjectsThe JasperPrint object is the created after the JasperReport Object, a JRDataSource and a map of parameters have been passed into the JasperFillManager. This is the object that can be passed to a JasperExportManager to create an output (HTML, Excel, CSV, etc). Now you might ask, why not just create the JasperPrint directly using the API. To see how to create a JasperPrint please review this: http://jasperreports.sourceforge.net/sample.reference/noreport/index.html#noreport The issue with creating a JasperPrint object is there is not a clean way to add this functionality to the server. So for the purposes of this acticle we will be focusing on the JasperDesign approach. Creating the JasperDesign ObjectThe best place to start when creating reports using the api is the following JasperReports Sample: http://jasperreports.sourceforge.net/sample.reference/noxmldesign/index.html As you can see a simple report has been created. For this example what we will do is that the getJasperDesign method from the NoXmlDesignApp sample object and put it into its own class. This will give us a class where we can call a static method to get a report design object. The change we are going to make it we are going to modify the signature of the method to also take a list of parameters. The Flexibility of SubReportsThe nice thing about subreports is their subreport expression, this is how the report design in located, can be of type JasperReport. The expression in this case can then be a call to the Java class created in the previous step. So basically what we will have in a main report that is just a wrapper and a subreport that creates the report design on the fly. Values captured from the user upon report execution can be passed into the call of the helper class. The data source for the subreport can be obtained from the parent report or defined in run time. Deploying Everything to the ServerOnce we have it all completed it can be deployed to the server giving you a very powerful and flexible report. LimitationsThe big limitation here is you will be able to design the subreport to be what you want, however it is stuck within the main report. This means the main report's orientation (ie: Landscape) will be what the subreport must work within. There are potential ways to work around this, however they require customization of the server code and are beyond the scope of this article. ConclusionThis technique is a great example of one of the benifits of having such a power tool as JasperReports powering JasperReports server. I hope this will be of value to you. Happy reporting!
  2. Hi; In the Query Designer window you need to make sure to either have the 'Automatically Retrieve Fields' check box selected, or click the button that says 'Read Fields'. At this point your query will be used to get the meta data from the tables you are selecting and appropriate java objects will be created in the JRXML as fields for each of the columns your query will return (see attached screen shot). I hope this helps. Luke Post Edited by lshannon at 06/15/2012 15:39
  3. I actually use System.outs to debug and simply run the report with the scriplet in iReport and view the output in the iReport console. An alternative could be to look at the demo/samples folder of the JasperReports source. It contains java examples of executing a report. You might be able to craft a unit test based on these that you could run in Eclipse. I hope that helps.
  4. I have never worked with this exporter, however I know that some exporters (like html) will produce strange results like this if there are elements overlapping. For a small experiment perhaps reduce the elements of your report till you have a very simple report (perhaps just writing out one field). Test that to see if you have the sample result. Also perhaps try an HTML export, if that contains blanks then you might have some over lap. Again I have not worked with the ODT exporter so this is purely a guess. Good luck.
  5. OK. I have done some more research. It seems chart themes is more of an extension of JasperReports, rather than part of the core. If you look in JasperServer there is a jar file called jasperreports-chart-themes-x.jar. Within that jar are the classes and xml files you are mentioning. iReport contains something similar in its classpath. These classes/xml files are required for JasperReports to be able to make use of the JRCTX file. The pom file included in the samples generates these jars so you can add them to you own app if you plan to use themes. Once these files have been deployed to the classpath you can add a JRCTX to the classpath. You will also need to set the appropriate properties files referencing your theme. I notice the new version of iReport 3.7 creates this file for you when you export your them to a jar. I hope this helps. Post Edited by lshannon at 01/14/2010 18:03
  6. I was just looking at the JasperReports reference. There is a setting for the chart theme. This could be part of the missing puzzle you are looking for. This could be set in the jasperreports.properties file (in the classes folder of a web application) or within the report definition itself as a property. http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.chart.theme
  7. I took a look through the JasperReports pom.xml. The only reference to jdt I can see is: <dependency> <groupId>eclipse</groupId> <artifactId>jdtcore</artifactId> <version>3.1.0</version> <scope>compile</scope> </dependency> You should post this question in the JasperReports forum instead. You may get better answers from there.
  8. When I am working with Chart Themes I export them to a jar (version 3.7 of iReport has a feature for this). Then I add the jar to the iReport classpath for designing and testing. When it is time to deploy I make sure the jar goes into the application classpath with all the other jars. I hope this helps.
  9. This will provide some useful insight as well: http://jasperforge.org/projects/jasperreports/tracker/view.php?id=2782
  10. If I understand it correctly, when this property is used, content for a group that will not all fit on the current page is moved to the next page. I think it is similar to the spitType property, but for a group. I plan to play with the property myself to get a better understanding. Hopefully this helps.
  11. When you say "I do not want certain fields bands", is it a band or a field you wish to hide in the output? Are you hosting this report in your own application or JasperServer? If it is your own, you should be able to detect when the user has chosen an excel output. Then you can declare a boolean Parameter in your design, which could be named something like OUTPUT_IS_EXCELL. This would be false by default, however when you detect a user wants Excel, you could set it to be true. Using this parameter to you can create PrintWhenExpressions to both bands and fields to your design. As to your other question, I took a quick peak at the source and it looks like in the JRBaseFiller class there is a method called setIgnorePagination that sets the value of the parameter to Boolean.FALSE if it is not true.
  12. Rather than a parameter I was suggesting doing this in the datasource expression for the list. In iReport if you right click on the list element in the design and select "edit list datasource" you will be presented with a pop up to configure the datasource. Make sure "Use Datasource expression" is selected in the Connection/Datasource expression combo box and place something like this as the expression: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(studentObjectArrayList)
  13. When you mean "crossed" do you mean you want to use the dates obtained from one query in the select statement of another? Are they both from the same DB? What about doing everything in a stored proc and then call that from the report? Also some sort of ETL process might be handy. Does the data need to be real time? Post Edited by lshannon at 01/06/2010 17:21
  14. What is the desired effect you are looking for? I am not clear what is you are after. Have you tried playing with the isStretchWithOverflow="true" setting on the textfields? You can increase the height of the band if you increase the height of the page. What is the output you working with? PDF, HTML, Excel? Perhaps you can go with a non standard paper size?
  15. I would reccomend posting this question in the JasperServer forum. This is the iReport forum, iReport being our report designer and JasperServer being our hosting environment. I would guess there are people in the JasperServer forum that may have attempted such an integration. I don't know Oracle apps at all, however for integrating reports built with iReport into another web application you can use JasperServer's web services API. If you download JasperServer and install it with the samples, you will find in the samples folder of the installation some example web services implementations (java, c and php). There is also documentation on the API with the install. You can also download the JasperReports source code. In the source see the folder demo/samples/webapp for some examples how to use the JasperReports API directly to add a JasperReport to an existing web application (java). I hope this helps.
×
×
  • Create New...