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

lshannon

Members
  • Posts

    182
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by lshannon

  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.
  16. I am sorry, I don't understand what your issue is. Do you want to create a crosstab in iReport like the mock up you provided? Or do you already have something working in iReport however there is an issue with it?
  17. What is the datasource expression you are trying when you pass in the student list? I would think something like the datasource expression below would work: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(studentObjectArrayList)
  18. I am not an expert with this product, however I have used it a couple of times and found it quite useful when your requirements demand a very specific output (sortable HTML is a perfect example). I recently used it with JasperServer 3.5.1 (tomcat,mysql), JasperReports 3.5.0 and iReport 3.5.0 without issues. If I recall correctly (if I am wrong I'm sure someone will correct me), set up in JasperServer is as simple as a small modification to the web.xml, the addition of a new Jar(s), adding some javascript files and then adding the velocity templates the exporter will use. When you deploy the report built in iReport to JasperServer, in the customization section you reference a custom JSP page you will create to ensure your output is generated by the template exporter. Most of the work will be done in your velocity templates. At the report level there are some custom properties you need to ensure are in place. The package contains a sample report and velocity template you can follow to get started. Hope this helps and let me know if you need more details.
  19. You can get a reference to a report object (JasperDesign) that can be modified from the .jasper, but this would require some customizations to your run time environment. However, the main issue is modifying the JasperDesign object using the API, while maintaining a good layout, will be tricky. Instead you should be able to do this sort of logic in your design. All elements of a report have PrintWhenExpression (in iReport you can check the properties of the subreport element to find this). Using this expression you can hide and show things in runtime based on an expression (expressions can use fields, variables and parameters). The issue you will run into now is shifting your layout around to fill in the gaps after something is hidden. There are some settings you could play with like "Remove Line When Blank" to compensate for this. I hope this helps. Post Edited by lshannon at 12/08/2009 17:17 Post Edited by lshannon at 12/08/2009 19:05
  20. If you are exporting to HTML for this report, you might be able to do get your desired result by first setting a Custom Property on the element. Then create an extension of the HTML exporter to detect these properties and generate the hyperlink code you are looking for. I hope this helps. Post Edited by Luke Shannon at 03/24/09 15:45
  21. Hi Chris; One thing to remember, TextFields can dynamically grow vertically, but not horizontally. To get verical stretch behavior, ensure you have a decent sized width and then make sure the property "Stretch with Overflow" is selected (in a text field you will find this by right clicking on the text field in the designer properties -> text field). Ensure any elements below this one have a Position Type = Float (this means this will move down when something above them increases in height). HTH
  22. I would guess you would just need to add: net.sf.jasperreports.engine.JasperFillManager=debug To a log4J file in your projects class path. Hope this helps.
  23. I think you will need to pass each value up to the main (from report 1 and report 2) and create a variable in the main that calculates the difference. Then pass that variable down to report 3 for display from the main. Check out demo/samples/subreport in the JR source for an excellent example of passing values back and forth between master and subreports. I hope this helps.
  24. You need to do a couple of things. 1. Compile all the java files in the folder with the sample report (ant javac will do it). 2. In iReport modify your classpath to point to the folder with the sample report. 3. Restart iReport. The class the image expression is referencing is in the src folder of the sample reports directory. I hope this helps.
  25. Could this be a timing issue? Maybe try putting the export code in its own thread, then have the main thread sleep for the max fill times you have seen your report take?
×
×
  • Create New...