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

rainer.stuelp

Members
  • Posts

    6
  • Joined

  • Last visited

rainer.stuelp's Achievements

Rookie

Rookie (2/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. I found a solution how it works. public class Dot { Long x; Double y; String graphName;// Getter and Setter here}public class Chart { ArrayList<Dot> punkte;// Getter and Setter here}[/code]Each dot needs to know to which series it belongs. So, the series value must be $F{graphName} JasperReports detects a new series name and starts with a new series
  2. Hi, I am using JAVA with beans to create a jasper report with a chart that has two series. The data I put to tje JasperFillManager has the following structure: public class Dot { Double x; Double y;// Getter and Setter here ...}public class Payload { ArrayList<Dot> defaultPoints; ArrayList<Dot> sprintPoints; // Getter and Setter here ...}...Map<String,Object> parameters = new HashMap<String,Object>();Payload payload = new Payload();// fill payload with values for defaultPoints and sprintPoints...parameters.put("payload", payload);...JasperPrint jasperPrint = JasperFillManager.fillReport(reportPath, parameters);[/code]I have a main report (including a parameter "payload") which contains a subreport. In the subreport I want to draw the chart. The subreport has the paraneter "payload", too and the main report is passing the value to the subreport. The subreport has two fields: x: java.lang.Double y: java.lang.Double I inserted a char element (XY Line) and set Y value to $F{y} and X value to $F{x}. I have added two series. How can I assign defaultPoints to Series 1 and sprintPoints to Series 2? Regards, Rainer
  3. Hi, after getting Jasperreports working with my JAVA beans, I have layout problems. I am designing the report files (.jrxml) with Jaspersoft Studio 6.11. I am planing to design the report similar to an existing HTML page. I am passing my JAVA beans to a parameter called "payload". In my mainreport I declared a parameter with the name "payload" and the class is identical to the JAVA class of my JAVA bean. Because of multiple ArrayLists in my JAVA bean, I am using multiple subreports. Each report has its own "Data Source Expression" command ( for example: "new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{payload}.getProductInformation())" ). In each subreport I want to use a list element or a table element (both from the Basic Elements list). The data of each dataset is printed in the report, so the databinding is working. Now here are my current layout problems. Problem 1 I can't change the default row height of a table. The gap between each row of the table is too large. Problem 2 To get a workaround for Problem 1 I tried to use the list element. The gap between each row is fine, but the lines with more characters are wraped. When I select the list element I see a blue vertical line. I think this is the limitation of line length. How can I extend the line length so the max. line length is equal to my size values from the Appearance property page? Problem 3 Because of using multiple subreports, the next subreports should be printed at the position where the current subreport end. When I put the reports to (for example) the page header band, the subreports will overlapped if the content is longer than expected. When I create multiple detail bands and put each subreport to one detail band, the final report wont display any of the detail bands. How mus I configure / create my report to print each subreport after another and if the remaining subreports don't fit to the current page, they will be printed to the second page? I hope someone can help me. Best regards, Rainer
  4. Finally I got the detail band working. In JAVA it looks like this: ReportBean myData = generateReportData();Map<String, Object> parameters = new HashMap<>();parameters.put("myData", myData);JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(myData.getCars());JasperPrint jasperPrint = JasperFillManager.fillReport(path, parameters, datasource);[/code]In JasperStudio I created two fields in the main report. The name of the fields is identical to the variable names in the bean. public class CarBean { private String manufacturer; private String model; public String getManufacturer() {return manufacturer;} public void setManufacturer(String manufacturer) {this.manufacturer = manufacturer;} public String getModel() {return model;} public void setModel(String model) {this.model = model;}}[/code]main.jrcml <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Main" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0a383bf6-cd61-4478-8f63-472de51e2fc7"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <parameter name="myData" class="org.example.SamplePDF.bean.ReportBean"/> <queryString> <![CDATA[]]> </queryString> <field name="model" class="java.lang.String"> <field name="manufacturer" class="java.lang.String"/>[/code]In the main report I set the property the Data Source Expression of the subreport to new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{myData}.getCars())[/code]After that I created the same field elements in the subreport. The value of the Text Field controls are set to $F{manufacturer} and $F{model} After that the report is filled as I want it. I hope this little tutorial will help someone else. Regards, Rainer
  5. Hi, thank you very, very much for your answer. Now I got the parameters working. Passing parameters from the main report to the subreports works, too. But now, I have one more problem: Here is my source code: CarBean.java: package org.example.SamplePDF.bean;public class CarBean { private String manufacturer; private String model; public String getManufacturer() { return manufacturer; } public void setManufacturer(String manufacturer) { this.manufacturer = manufacturer; } public String getModel() { return model; } public void setModel(String model) { this.model = model; }}[/code]ReportBean.java package org.example.SamplePDF.bean;import java.util.ArrayList;public class ReportBean { private EmployeeBean employee; private ArrayList<CarBean> cars; public EmployeeBean getEmployee() { return employee; } public void setEmployee(EmployeeBean employee) { this.employee = employee; } public ArrayList<CarBean> getCars() { return cars; } public void setCars(ArrayList<CarBean> cars) { this.cars = cars; }}[/code]Question 1: In one of the subpages I want to iterate through the ArrayList<CarBean>. I know, that I have to use the detail band. But how do I have to assign my datasource to the report? Question 2: If I have two subreports and two arrays in my class (not an array of an array, but one array for cars and a second one for planes e.g.), how do I have to set multiple data sources? If you can help me one more time, it would be great. Regards, Rainer
  6. Hi, I am developing an Angular frontend and JAVA springboot REST backend. The backend should create a PDF file and send it to the user. To create the PDF file I want to user JasperReports. I am using OpenJDK 13 IntelliJ Jasper Reports 6.11.0 Maven I have created a small abstract application which represents all relevant functions of my final REST backend project. The project creates an object of the class ReportBean with the following structure (here some example values in JSON format) { "employee": { "name": "John Doe", "age": 25 }, "cars": [{ "manufacturer": "Ford", "model": "Mustang" }, { "manufacturer": "Dodge", "model": "Viper" }, { "manufacturer": "Mercedes", "model": "SLK" } ]}[/code]The layout (one main report with two subreports) should be like the following: I found a JAVA tutorial to create a PDF report. All function calls from the tutorial are used in the Main class (s. atttachment). Before adding some custom parameters or data from a JAVA object / bean, I set the following parameter on the MAIN of each report: "When No Data Type" = "All Sections No Detail". Without setting this parameter I got an empty report. Here are my problems: First Problem: How to insert the current Date to the report? (top right in the main report) Second problem: How to use parameters in the reports? I have added a custom parameter named "object" with the value "Hello World" in my JAVA project and assigned it to a HashMap for the JasperFillManager. I created a custom paremter in my report, too, so the JasperCompilerManger doesn't throw an error. Third problem (and this is the main problem): How cann I use my JAVA object to fill my main- and subreport? In the internet I found some examples and tutorials which didn't work. :-( When I try to create a Data Adapter, I can only select a Java Bean collection. But I don't have a collection. When I follow the examples and tutorials that are using a Java Bean collection, I don't see any bean data when creating a Data Bean connection in the Jasper Studio. So, I hope someone has some useful hints for me or someone is so kind as modifying my project. Regards, Rainer
×
×
  • Create New...