JRException: resources not found at :GuestFolio_super.jasper [duplicate] - jasper-reports

I made a jasper report that includes a subreport using JasperSoft Studio. When i preview it in the studio, it works fine. But when i add it into my java fx project, i have to send the subreport as a parameter to the main report right?
When i do that i keep on getting an error saying that the subreport resource not found.
I dont think there is any spelling errors because i hv tried this with almost all the reports that includes subreports.. still keep on getting that error..
These are the things i tried
1. compiled the report again using the jaspersoft studio and includeded them again in the project..
2. included the jrxml file into the project and compiled it with the Compile Manager..
3. i read some tutorials and questions saying that to put the expression to the subreport element in the main report as
$P{SUBREPORT_DIR} + "subreport_2.jasper"
but i still keep on getting the same error and i dont know what i am doing wrong
Below is my code
method in application used to view the report
#FXML
public void btnMarkingSchemeClicked(ActionEvent actionEvent) {
try {
// JasperReport compiledReport = (JasperReport) JRLoader.loadObject(ViewAssignmentsController.class.getResourceAsStream("/edu/ijse/gdse41/ams/reports/MarkingScheme.jasper"));
JasperReport compiledReport = JasperCompileManager.compileReport(ViewAssignmentsController.class.getResourceAsStream("/edu/ijse/gdse41/ams/reports/MarkingScheme.jrxml"));
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("assignID", aid);
parameters.put("course", cmbCourse.getSelectionModel().getSelectedItem().toString());
parameters.put("subject", cmbSub.getSelectionModel().getSelectedItem().toString());
parameters.put("semester", cmbSem.getSelectionModel().getSelectedItem().toString());
parameters.put("assign", ctrlAssign.search(aid).getAssignName());
// JasperReport subReport = (JasperReport) JRLoader.loadObject(ViewAssignmentsController.class.getResourceAsStream("/edu/ijse/gdse41/ams/reports/Answers.jasper"));
JasperReport subReport = JasperCompileManager.compileReport(ViewAssignmentsController.class.getResourceAsStream("/edu/ijse/gdse41/ams/reports/Answers.jrxml"));
parameters.put("subReport", subReport);
JasperPrint fillReport = JasperFillManager.fillReport(compiledReport, parameters, ConnectionFactory.getInstance().getConnection());
JasperViewer.viewReport(fillReport, false);
} catch (JRException | SQLException | ClassNotFoundException ex) {
Logger.getLogger(ViewAssignmentsController.class.getName()).log(Level.SEVERE, null, ex);
}
}
my main report source -- MarkingScheme.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-02T12:52:20 -->
<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="MarkingScheme" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c71b946b-2ba2-4208-97f8-f32e8bcf3fb4">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="amsAdapter"/>
<parameter name="course" class="java.lang.String"/>
<parameter name="subject" class="java.lang.String"/>
<parameter name="semester" class="java.lang.String"/>
<parameter name="assign" class="java.lang.String"/>
<parameter name="assignID" class="java.lang.String">
<defaultValueExpression><![CDATA[$P{assignID}]]></defaultValueExpression>
</parameter>
<parameter name="subReport" class="net.sf.jasperreports.engine.JasperReport">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[$P{subReport}]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
<![CDATA[SELECT ams.question.qid,
ams.question.question,
ams.assign_ques.aid
FROM ams.assign_ques
INNER JOIN ams.question ON
ams.assign_ques.qid = ams.question.qid and ams.assign_ques.aid=$P{assignID}]]>
</queryString>
<field name="qid" class="java.lang.String"/>
<field name="question" class="java.lang.String"/>
<field name="aid" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="555" height="79" forecolor="#FFFFFF" backcolor="#113891" uuid="52ed193a-ed11-46ba-a09f-1864b843df96"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="29" isBold="true"/>
</textElement>
<text><![CDATA[ Marking Scheme]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="80" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="80" height="40" uuid="55b35bb0-5ea8-4417-88be-0083cfee5037"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Course]]></text>
</staticText>
<staticText>
<reportElement x="0" y="40" width="80" height="40" uuid="1dc04c2d-9cde-4905-9650-03cc96d406e3"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Semester]]></text>
</staticText>
<staticText>
<reportElement x="260" y="0" width="100" height="40" uuid="4de2dbe2-bb88-4dbf-88d7-16b36bba8fb4"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Subject]]></text>
</staticText>
<staticText>
<reportElement x="260" y="40" width="100" height="40" uuid="bb91c5d3-4cde-45eb-8083-012fe6183396"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Assignment]]></text>
</staticText>
<textField>
<reportElement x="90" y="0" width="160" height="40" forecolor="#123278" uuid="8016c655-1bea-480a-9179-3da4e1e930ad"/>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$P{course}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="370" y="0" width="170" height="40" forecolor="#123278" uuid="23e58b4b-0bf1-41ae-89f0-48808a0abdd9"/>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$P{subject}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="90" y="40" width="160" height="40" forecolor="#123278" uuid="650c412a-0c42-4dea-a96f-35d03c11c926"/>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$P{semester}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="370" y="40" width="170" height="40" forecolor="#123278" uuid="c8cbea5b-afb3-4c85-a96a-156d1c82fb50"/>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$P{assign}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="30" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="f7b84a13-8e80-4c9c-8888-3b081f9d0f55"/>
<textElement>
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Questions]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="41" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="80" height="20" uuid="9f05a7d2-ac5f-4412-b26b-ab37033cc0fe"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{qid}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="440" height="20" uuid="a299bfe0-a0d1-4aae-8f75-5b58d24b1760"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{question}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="100" y="20" width="440" height="20" uuid="72f8c7c2-82ca-48d3-bb89-d5bb4846e1bc"/>
<subreportParameter name="qid">
<subreportParameterExpression><![CDATA[$F{qid}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["Answers.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
my sub report source -- Answers.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-02T12:53:52 -->
<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="Answers" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="142adbc1-da50-458b-b076-ba8aa716124f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="amsAdapter"/>
<property name="com.jaspersoft.studio.data.sql.tables" value="YW1zLmFuc3dlciAsMTUsMTUsOGE1MjQ1NzQtOGY1ZS00ZWY4LWFiMDAtOWVjYmVmNmU0MTFjOw=="/>
<parameter name="qid" class="java.lang.String">
<defaultValueExpression><![CDATA[$P{qid}]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT ams.answer.answer_id,
ams.answer.answer,
ams.answer.correctness,
ams.answer.qid
FROM ams.answer where ams.answer.qid=$P{qid} and ams.answer.correctness=1]]>
</queryString>
<field name="answer_id" class="java.lang.String"/>
<field name="answer" class="java.lang.String"/>
<field name="correctness" class="java.lang.Boolean"/>
<field name="qid" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="80" height="20" uuid="517ba9e8-6637-4808-8517-1485d4125971"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{answer_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="90" y="0" width="460" height="20" uuid="4384510c-5dea-47a0-b24b-d4b3bd4088fc"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{answer}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
the error im getting
net.sf.jasperreports.engine.JRException: Resource not found at:
Answers.jasper. at
net.sf.jasperreports.repo.RepositoryUtil.getResourceFromLocation(RepositoryUtil.java:153)
at
net.sf.jasperreports.repo.RepositoryUtil.getReport(RepositoryUtil.java:112)
at
net.sf.jasperreports.engine.fill.JRFillSubreport.loadReport(JRFillSubreport.java:398)
at
net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:365)
at
net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:427)
at
net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:341)
at
net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
at
net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
at
net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:582)
at
net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:90)
at
net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456)
at
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863)
at
edu.ijse.gdse41.ams.view.controller.ViewAssignmentsController.btnMarkingSchemeClicked(ViewAssignmentsController.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) at
sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) at
javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769) at
javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at
com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at
com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at
javafx.event.Event.fireEvent(Event.java:198) at
javafx.scene.Node.fireEvent(Node.java:8413) at
javafx.scene.control.Button.fire(Button.java:185) at
com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at
com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at
com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at
com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at
com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at
com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at
javafx.event.Event.fireEvent(Event.java:198) at
javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at
javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at
javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at
javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at
com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at
com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method) at
com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
at
com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at
com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at
com.sun.glass.ui.View.notifyMouse(View.java:937) at
com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at
com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)

It is because even though you have created a parameter called "subReport" it hasn't been used anywhere.
<subreport>
<reportElement x="100" y="20" width="440" height="20" uuid="72f8c7c2-82ca-48d3-bb89-d5bb4846e1bc"/>
<subreportParameter name="qid">
<subreportParameterExpression><![CDATA[$F{qid}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["Answers.jasper"]]></subreportExpression>
</subreport>
See? It is still "Answers.jasper" there in the main report. That is why it works fine in Jasper Studio. Let's change it to,
<subreport>
<reportElement x="100" y="20" width="440" height="20" uuid="72f8c7c2-82ca-48d3-bb89-d5bb4846e1bc"/>
<subreportParameter name="qid">
<subreportParameterExpression><![CDATA[$F{qid}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{subReport}]]></subreportExpression>
</subreport>
I am pretty sure that I am not the one who taught you to use Jasper :)
Let's hope it will work

In MarkingScheme.jrxml change from
<subreportExpression><![CDATA["Answers.jasper"]]></subreportExpression>
to
<subreportExpression><![CDATA[$P{subReport}]]></subreportExpression>
Change the class adding the Answers.jasper including its path.
parameters.put("subReport", "/edu/ijse/gdse41/ams/reports/Answers.jasper");
The path must be completed starting from the root context (/).

Your subreportExpression tag should expect $P{SUBREPORT_DIR} + "Answer.jasper" like the following:
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "Answer.jasper"]]></subreportExpression>
And you need to provide the path dynamically from your context for $P{SUBREPORT_DIR}
I am using Groovy on Grails! Basically, the report misses the value of parameter for SUBREPORT_DIR in jrxml.
My reports and subReports are in web-app/reports folder. So, while generating report with subReport, I added a path value like the following:
params.put('SUBREPORT_DIR', getReportDirectory() + File.separator)
where getReportDirectory() function looks like the following:
def getReportDirectory() {
String REPORT_DIRECTORY = null;
if (!REPORT_DIRECTORY) {
File reportFolder = ApplicationHolder.application.parentContext.getResource('/reports').file;
REPORT_DIRECTORY = reportFolder.absolutePath;
}
return REPORT_DIRECTORY;
}

Related

How to split details across multiple columns while programmatically appending 'continuation' message for subsequent sections?

I have a customer request to split details of personal information (name, address, secondary addresses, etc) across multiple columns, if the dynamic size does not fit in the current column. As a caveat, the name field, followed by the word '(Continued)', is desired, as the title for the segments in subsequent columns.
Is this behavior possible with jasper-reports?
I have tried toggling an 'inBetween' flag with the beforeDetailEval() and afterDetailEval() hooks, checking that flag in the column header band, to optionally reprint the name + 'Continued', but the column header always calls the scriptlet method AFTER the afterDetailEval() method (does not make sense to my little mind), failing since the 'inBetween' flag is reset to false.
(Note: Detail band has been set with splitType to both 'Immediate' and 'Stretch', but neither approach has behaved as expected. The entire band just gets restarted at the beginning of the next column)
Is this possible, and if so, are there any suggestions for creative solutions for this scenario?
Also, there is strange behavior displaying where if a detail is split across multiple columns, the first part of the detail (up to the subreport element)is duplicated on the following column. This behavior is also undesirable to the customer, and needs to be adjusted so nothing (except the title) is duplicated.
This is the syntax desired by the customer:
Name 1 Name 2
Address 1 (Continued)
City 1 AL – Address 3
State 1 AL - City 3
Zip 1 AL - State 3
Additional Locations: AL - Zip 3
AL-Address 1 ...
AL-City 1
AL-State 1
AL-Zip 1
AL-Address 2
AL-City 2
AL-State 2
AL-Zip 2
Name 2
Address 2
City 2
State 2
Zip 2
Additional Locations:
AL-Address 1
AL – City 1
AL-State 1
AL – Zip 1
AL – Address 2
AL – City 2
AL – State 2
AL – Zip 2
This is what we are actually getting:
Name1 Name1
Address1 Address1
City1 City1
State1 State1
Zip1 Zip1
Additional Locations Additional Locations
AL-Name1 AL-City2
AL-Address1 AL-State2
AL-City1 AL-State2
AL-State1
AL-Zip1
AL-Name2
AL-Address2
This is a sample main jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-22T09:48:08 -->
<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="Blank_A4" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="path.to.my.scriptlet" uuid="af53d807-7975-4ff7-bfc5-e438944aa795">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="Address" class="java.lang.String"/>
<field name="City" class="java.lang.String"/>
<field name="State" class="java.lang.String"/>
<field name="Zip" class="java.lang.String"/>
<field name="AdditionalLocations" class="java.util.List"/>
<variable name="IN_MIDDLE_OF_DETAIL" class="java.lang.Boolean" calculation="System">
<initialValueExpression><![CDATA[Boolean.False]]></initialValueExpression>
</variable>
<columnHeader>
<band height="74" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="-10" y="0" width="100" height="30" uuid="258dce49-fb61-4887-bb30-69e80e96d8f1">
<printWhenExpression><![CDATA[$V{IN_MIDDLE_OF_DETAIL}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="-10" y="40" width="100" height="30" uuid="c18b2fab-900b-4641-aaef-2520510a3510">
<printWhenExpression><![CDATA[$V{IN_MIDDLE_OF_DETAIL}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA["(CONTINUED)"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="426" splitType="Stretch">
<textField>
<reportElement x="0" y="10" width="100" height="30" uuid="853a1b0d-a49e-45c4-8183-83cfd69bf5af"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="100" height="30" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba"/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="90" width="100" height="30" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="120" width="100" height="30" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"/>
<textFieldExpression><![CDATA[$F{State}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="160" width="100" height="30" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"/>
<textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="220" width="100" height="110" uuid="8ef583fd-fa23-47d8-80d0-90de4f6478a0"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{AdditionalLocations})]]></dataSourceExpression>
<subreportExpression><![CDATA["Blank_A4_1.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="10" y="198" width="100" height="30" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"/>
<text><![CDATA[Additional Locations]]></text>
</staticText>
</band>
</detail>
</jasperReport>
This is the sample subreport jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-22T10:39:43 -->
<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="Blank_A4_1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729">
<queryString>
<![CDATA[]]>
</queryString>
<field name="Address" class="java.lang.String"/>
<field name="City" class="java.lang.String"/>
<field name="State" class="java.lang.String"/>
<field name="Zip" class="java.lang.String"/>
<detail>
<band height="168" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="10" width="100" height="30" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="100" height="30" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="89" width="100" height="30" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"/>
<textFieldExpression><![CDATA[$F{State}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="130" width="100" height="30" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"/>
<textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
This is the basic scriptlet code to toggle the value of IN_MIDDLE_OF_DETAIL:
#Override
public void beforeDetailEval() throws JRScriptletException
{
setVariableValue("IN_MIDDLE_OF_DETAIL", Boolean.TRUE)
}
#Override
public void afterDetailEval() throws JRScriptletException
{
setVariableValue("IN_MIDDLE_OF_DETAIL", Boolean.FALSE)
}
Drop the scriptlet, there is no need for this, lets use the fact that subreport's has its own page count, hence when it breaks in main report it counts a page
The solution I would use is the pageHeader band in the subreport with a printWhenExpression on page number (>1).
Which means that the text that you like to display when subreport splits to new "page" (name and "Continue") goes into pageHeader of the subreport and should be printed on all subreport "pages" except the first one.
Since name does not seems to be part of the subreport datasource I will pass this as a parameter to the subreport.
Code in subreport to display header when page > 1
<pageHeader>
<band height="44">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}>1]]></printWhenExpression>
<textField>
<reportElement x="0" y="0" width="220" height="20" uuid="8cce4cab-6ccf-4ddb-b1f1-508dc97bfcfe"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="220" height="19" uuid="c18b2fab-900b-4641-aaef-2520510a3510"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["(Continued)"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
Example output
I have cut down page height to reduce image
Full example
**main report jrxml**
<?xml version="1.0" encoding="UTF-8"?>
<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="Blank_A4" columnCount="2" pageWidth="595" pageHeight="500" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="af53d807-7975-4ff7-bfc5-e438944aa795">
<queryString>
<![CDATA[]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="zip" class="java.lang.String"/>
<field name="additionalLocations" class="java.util.List"/>
<detail>
<band height="141" splitType="Immediate">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="20" width="280" height="20" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="40" width="280" height="20" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="60" width="280" height="20" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="80" width="280" height="20" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zip}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="120" width="280" height="20" isPrintWhenDetailOverflows="true" uuid="8ef583fd-fa23-47d8-80d0-90de4f6478a0"/>
<subreportParameter name="name">
<subreportParameterExpression><![CDATA[$F{name}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{additionalLocations})]]></dataSourceExpression>
<subreportExpression><![CDATA["C:/Users/pette/JaspersoftWorkspace/MyReports/SplitSubreport.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="0" y="100" width="280" height="20" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"/>
<textElement verticalAlignment="Middle">
<font isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[Additional Locations]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="280" height="20" uuid="258dce49-fb61-4887-bb30-69e80e96d8f1"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
**subreport jrxml**
<?xml version="1.0" encoding="UTF-8"?>
<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="Blank_A4_1" pageWidth="280" pageHeight="200" columnWidth="280" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729">
<parameter name="name" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="zip" class="java.lang.String"/>
<pageHeader>
<band height="44">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}>1]]></printWhenExpression>
<textField>
<reportElement x="0" y="20" width="220" height="19" uuid="c18b2fab-900b-4641-aaef-2520510a3510"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["(Continued)"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="220" height="20" uuid="8cce4cab-6ccf-4ddb-b1f1-508dc97bfcfe"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="85" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="-1" width="220" height="21" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="20" width="220" height="20" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="40" width="220" height="20" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="60" width="220" height="20" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zip}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

Field not found in report

I try to create a JasperReport's report with charts but getting error. I used table in the report and pie chart. Where I did wrong ?
I want to use same fields for reports and charts but I don't know how to use in both components.
Error:
Fields not found : campaignName
Fields not found : numTransmissions
<?xml version="1.0" encoding="UTF-8"?>
<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="template_Table" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoPages" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<subDataset name="Dataset1">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<field name="campaignName" class="java.lang.String"/>
<field name="numTransmissions" class="java.lang.Integer"/>
<group name="Group1">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/15)]]></groupExpression>
</group>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
</group>
<detail>
<band height="449" splitType="Stretch">
<componentElement>
<reportElement stretchType="RelativeToTallestObject" mode="Transparent" x="0" y="0" width="800" height="199" forecolor="#FFFFFF" backcolor="#424242">
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Dataset1"/>
<jr:column width="52">
<jr:tableHeader height="70">
<staticText>
<reportElement x="0" y="0" width="52" height="70"/>
<box leftPadding="3"/>
<textElement textAlignment="Left" verticalAlignment="Middle" markup="html">
<font fontName="Verdana" size="9"/>
</textElement>
<text><![CDATA[Campaign Name]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell height="50">
<textField>
<reportElement x="0" y="0" width="52" height="50"/>
<box leftPadding="6"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Verdana"/>
</textElement>
<textFieldExpression><![CDATA[$F{campaignName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="53">
<jr:tableHeader height="70">
<staticText>
<reportElement x="0" y="0" width="53" height="70"/>
<box leftPadding="3"/>
<textElement textAlignment="Left" verticalAlignment="Middle" markup="html">
<font fontName="Verdana" size="9"/>
</textElement>
<text><![CDATA[Email Transmissions]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell height="50">
<textField>
<reportElement x="0" y="0" width="53" height="50"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{numTransmissions}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<summary>
<band height="400" splitType="Stretch">
<pieChart>
<chart evaluationTime="Report">
<reportElement x="135" y="0" width="270" height="300"/>
<chartTitle>
<titleExpression><![CDATA["My First JR Pie Chart"]]></titleExpression>
</chartTitle>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{campaignName}]]></keyExpression>
<valueExpression><![CDATA[$F{numTransmissions}]]></valueExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</summary>
</jasperReport>

Understanding Jrxml with a custom datasource

I am creating a Jasper report using a custom datasource.
I am using iReport to create the report.
Although I can see report working following various articles on web, I fail to understand how the generated Jrxml knows that it is supposed to fetch data from a custom JRDatasource ?
I can't see Jrxml pointing to my custom datasource class anywhere ???
Can someone provide more information ?
Here is the generated Jrxml
<?xml version="1.0" encoding="UTF-8"?>
<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="test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a19f56bb-4764-4dad-8177-9a410a0cb69d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="productCode" class="java.lang.String"/>
<field name="stockLevelStatus" class="java.lang.String">
<fieldDescription><![CDATA[stockLevelStatus]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="10" y="60" width="100" height="30" uuid="53ec360c-996a-48eb-9777-efbb9d5fa3d7"/>
<textFieldExpression><![CDATA[$F{productCode}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="0" width="100" height="30" uuid="dc8fcc8f-6294-4d5b-97de-4b68d2e6bb8b"/>
<text><![CDATA[productCode]]></text>
</staticText>
<textField>
<reportElement x="140" y="60" width="100" height="30" uuid="5219cffe-1786-4bd8-a8af-83eebda483cf"/>
<textFieldExpression><![CDATA[$F{stockLevelStatus}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="140" y="0" width="100" height="30" uuid="27edec96-50c6-4de0-830a-9593a0da7c17"/>
<text><![CDATA[stockLevelStatus]]></text>
</staticText>
</band>
</detail>
</jasperReport>
Can someone share Jrxml with custom datasource ?
Finally after a lot of R&D, I am able to solve the problem.
Here is the ".jrxml" file which allows you to plot a table in a Jasper report where table's data comes from a custom datasource.
You can find quite a few articles on web explaining how to write a custom datasource but none of them provides an example of how to use a custom datasource in a jrxml file.
<?xml version="1.0" encoding="UTF-8"?>
<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="custom" language="groovy" pageWidth="595" pageHeight="420" whenNoDataType="BlankPage" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" scriptletClass="de.hybris.platform.cockpit.reports.scriptlets.DateTimeScriptlet" resourceBundle="localization/jasperreports">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<subDataset name="custome_datasource">
<queryString>
<![CDATA[select 1 from DUAL]]>
</queryString>
<field name="productCode" class="java.lang.String"/>
<field name="stockLevelStatus" class="java.lang.String">
<fieldDescription><![CDATA[stockLevelStatus]]></fieldDescription>
</field>
</subDataset>
<queryString>
<![CDATA[select 1 from DUAL]]>
</queryString>
<title>
<band height="80" splitType="Stretch">
<staticText>
<reportElement x="10" y="0" width="500" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Stock Level Status Report]]></text>
</staticText>
</band>
</title>
<detail>
<band height="340" splitType="Stretch">
<componentElement>
<reportElement key="table" x="0" y="0" width="555" height="238"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="custome_datasource">
<dataSourceExpression><![CDATA[new my.dataproviders.StockLevelDataProvider()]]></dataSourceExpression>
</datasetRun>
<jr:column width="130">
<jr:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="92" height="25" backcolor="#99CCFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<text><![CDATA[ProductCode]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="10" width="90" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{productCode}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="130">
<jr:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="92" height="25" backcolor="#99CCFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<text><![CDATA[StockLevel]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="10" width="90" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{stockLevelStatus}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>

How to break the single Line chart into next pages

Can you please suggest the code for getting new pages.
How to break the single Line chart into next pages with JasperReports 5.0
Here the code i attached for more details.
<?xml version="1.0" encoding="UTF-8"?>
<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="SystemSummary" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bd0eaa3b-093e-4699-83ef-75015530229d">
<parameter name="whereClause" class="java.lang.String"/>
<parameter name="bankLogo" class="java.lang.String"/>
<parameter name="bankName" class="java.lang.String"/>
<parameter name="fromDate" class="java.util.Date">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<parameter name="toDate" class="java.util.Date"/>
<parameter name="noData" class="java.lang.String"/>
<parameter name="userId" class="java.lang.String"/>
<queryString>
<![CDATA[select avg(jbase_user) as jbaseAvg,AVG(t24_user) as t24Avg,to_char(load_time, 'dd.Mon.yy HH24') as period
from tmc_system_summary group by (to_char(load_time, 'dd.Mon.yy HH24'))]]>
</queryString>
<field name="jbaseavg" class="java.math.BigDecimal"/>
<field name="t24avg" class="java.math.BigDecimal"/>
<field name="period" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="2" splitType="Stretch"/>
</title>
<pageHeader>
<band height="57" splitType="Stretch">
<staticText>
<reportElement x="300" y="25" width="235" height="15" uuid="164831c1-9eff-4cf2-8706-331d28fdf431"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[System Summary Report]]></text>
</staticText>
<textField pattern="dd/MM/yyyy">
<reportElement x="735" y="2" width="55" height="17" uuid="306ddad6-2b80-4abb-9893-859c59c8ede5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="700" y="2" width="30" height="17" uuid="c6fdbff7-45a5-464e-bcbf-d550b174452f"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<text><![CDATA[Date:]]></text>
</staticText>
<image>
<reportElement x="20" y="3" width="130" height="30" uuid="513d2931-a2c7-4e54-bb86-188737502cae"/>
<imageExpression><![CDATA[$P{bankLogo}]]></imageExpression>
</image>
<staticText>
<reportElement x="20" y="40" width="58" height="14" uuid="5bd47ff1-6b81-428a-b7fd-50e777f70a22"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[From Date:]]></text>
</staticText>
<staticText>
<reportElement x="160" y="40" width="58" height="14" uuid="a7605d9e-c0d1-4a31-8230-c73db35766d4"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[To Date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy">
<reportElement x="80" y="40" width="70" height="14" uuid="faa13401-da98-4f06-ab43-5a1722d073f7"/>
<textFieldExpression><![CDATA[$P{fromDate} != null ? $P{fromDate} :" "]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy">
<reportElement x="215" y="40" width="70" height="13" uuid="01fcdb71-820f-4ef1-9913-6ddcf36be2dc"/>
<textFieldExpression><![CDATA[$P{toDate} != null ? $P{toDate} : " "]]></textFieldExpression>
</textField>
<textField>
<reportElement x="300" y="5" width="235" height="17" uuid="7eec4f6f-5bfd-4bb0-8888-8cad8d9d84ad"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="14" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression><![CDATA[$P{bankName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="700" y="22" width="30" height="15" uuid="08ba273e-733d-4652-9f7a-83a51f7d78ca"/>
<textElement textAlignment="Right"/>
<text><![CDATA[By:]]></text>
</staticText>
<textField>
<reportElement x="735" y="22" width="55" height="15" uuid="261308a5-7cef-42f8-8880-9d2c9cc5d5ae"/>
<textFieldExpression><![CDATA[$P{userId}]]></textFieldExpression>
</textField>
<line>
<reportElement x="10" y="54" width="780" height="1" uuid="062e928b-20d3-4345-a97e-b16eff81d254"/>
</line>
</band>
</pageHeader>
<columnHeader>
<band height="3" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="3" splitType="Stretch"/>
</detail>
<columnFooter>
<band height="2" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="27">
<textField>
<reportElement x="397" y="5" width="65" height="20" uuid="e40834ac-921f-4171-a500-ebfc9a43124a"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="273" splitType="Stretch">
<lineChart>
<chart>
<reportElement x..
i am using line chart, how can i split the graph and keeping all the data next pages
maybe you can try to change the "splitType" of summary band to "Immediate"

x axis value displayed in line chart

I have Line chart, in x axis i should display date in string format in full format, but i cant display when more no of values in x axis, for that i decided to display x axis values in vertical manner instead of horizontal , please suggest me. for ref attached image..
<?xml version="1.0" encoding="UTF-8"?>
<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="sampl1" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="431d18d3-722a-4aaf-8207-da8bb0ea2fdd">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="51"/>
<parameter name="whereClause" class="java.lang.String"/>
<parameter name="bankLogo" class="java.lang.String"/>
<parameter name="bankName" class="java.lang.String"/>
<parameter name="fromDate" class="java.util.Date">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<parameter name="toDate" class="java.util.Date"/>
<parameter name="noData" class="java.lang.String"/>
<parameter name="userId" class="java.lang.String"/>
<queryString>
<![CDATA[select avg(jbase_user) as jbaseAvg,AVG(t24_user) as t24Avg,to_char(load_time, 'dd.Mon.yy HH24') as period
from tmc_system_summary group by (to_char(load_time, 'dd.Mon.yy HH24'))]]>
</queryString>
<field name="jbaseavg" class="java.math.BigDecimal"/>
<field name="t24avg" class="java.math.BigDecimal"/>
<field name="period" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="30" splitType="Stretch"/>
</title>
<pageHeader>
<band height="67" splitType="Stretch">
<staticText>
<reportElement x="300" y="22" width="235" height="15" uuid="164831c1-9eff-4cf2-8706-331d28fdf431"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ System Summary Report]]></text>
</staticText>
<image>
<reportElement x="12" y="3" width="161" height="30" uuid="513d2931-a2c7-4e54-bb86-188737502cae"/>
<imageExpression><![CDATA[$P{bankLogo}]]></imageExpression>
</image>
<textField pattern="dd/MM/yyyy">
<reportElement x="735" y="2" width="55" height="17" uuid="306ddad6-2b80-4abb-9893-859c59c8ede5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="700" y="2" width="30" height="17" uuid="c6fdbff7-45a5-464e-bcbf-d550b174452f"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<text><![CDATA[Date:]]></text>
</staticText>
<staticText>
<reportElement x="20" y="40" width="58" height="14" uuid="5bd47ff1-6b81-428a-b7fd-50e777f70a22"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[From Date:]]></text>
</staticText>
<staticText>
<reportElement x="160" y="40" width="58" height="14" uuid="a7605d9e-c0d1-4a31-8230-c73db35766d4"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[To Date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy">
<reportElement x="80" y="40" width="70" height="14" uuid="faa13401-da98-4f06-ab43-5a1722d073f7"/>
<textFieldExpression><![CDATA[$P{fromDate} != null ? $P{fromDate} :" "]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy">
<reportElement x="215" y="40" width="70" height="13" uuid="01fcdb71-820f-4ef1-9913-6ddcf36be2dc"/>
<textFieldExpression><![CDATA[$P{toDate} != null ? $P{toDate} : " "]]></textFieldExpression>
</textField>
<textField>
<reportElement x="300" y="2" width="235" height="17" uuid="7eec4f6f-5bfd-4bb0-8888-8cad8d9d84ad"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="14" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression><![CDATA[$P{bankName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="700" y="22" width="30" height="15" uuid="08ba273e-733d-4652-9f7a-83a51f7d78ca"/>
<textElement textAlignment="Right"/>
<text><![CDATA[By:]]></text>
</staticText>
<textField>
<reportElement x="735" y="22" width="55" height="15" uuid="261308a5-7cef-42f8-8880-9d2c9cc5d5ae"/>
<textFieldExpression><![CDATA[$P{userId}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="54" width="802" height="1" uuid="e17b6ea4-40fd-40ad-861f-a300f926d0e4"/>
</line>
</band>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
![enter image description here][1] </columnHeader>
<columnFooter>
<band height="17" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="546" y="1" width="70" height="19" uuid="eeafb0de-dddb-4c9a-8a1d-942b65bf0a7f"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="392" splitType="Stretch">
<lineChart>
<chart>
<reportElement x="12" y="18" width="779" height="355" uuid="f696d665..
By this you can display the x axis value in vertical ( topDown)
<categoryAxisFormat labelRotation="90.0">
it will work.