In jasper Soft Studio ,I have 2 page footers. For footer1. I want the position should be normal, and for footer 2. I want position force to bottom [closed] - jasper-reports

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 months ago.
Improve this question
In jasper Soft Studio ,I have 2 page footers. For footer one, I want the position should be normal and for footer 2, I want position force to bottom. How can I do that?
If I am setting the position to force to bottom by default the position for both changes to force to bottom but I want one at bottom and second at normal.

I don't think you are using page footers. I'm assuming you have two footer bands for one group. As both of these footer bands belong to the same group they share the same properties. I'd say maybe use one group footer band (set to normal) and the page footer (which is at the bottom by default) or a second group with a same expression which will give you two independent group footers.
Here is an example that groups on $F{Country} with two (independent) groups.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.1.1 -->
<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_" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="62ac07f5-f11e-4179-aedb-a42e850c1ea8">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="northwind"/>
<queryString language="jsonql">
<![CDATA[Northwind.Customers]]>
</queryString>
<field name="City" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="City"/>
<fieldDescription><![CDATA[City]]></fieldDescription>
</field>
<field name="Country" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="Country"/>
<fieldDescription><![CDATA[Country]]></fieldDescription>
</field>
<field name="ContactName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="ContactName"/>
<fieldDescription><![CDATA[ContactName]]></fieldDescription>
</field>
<sortField name="Country"/>
<group name="City" footerPosition="ForceAtBottom">
<groupExpression><![CDATA[$F{Country}]]></groupExpression>
</group>
<group name="Group1">
<groupExpression><![CDATA[$F{City}]]></groupExpression>
</group>
<group name="Country 1" footerPosition="ForceAtBottom">
<groupExpression><![CDATA[$F{Country}]]></groupExpression>
<groupHeader>
<band height="52">
<textField>
<reportElement x="180" y="0" width="200" height="52" uuid="ecbaf5bf-be63-4f90-930c-dabb2c385d33"/>
<textElement textAlignment="Center">
<font size="35"/>
</textElement>
<textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement x="180" y="0" width="200" height="20" uuid="fc3ccc02-ea1b-4aa3-84d0-e40ba46f3966"/>
<textElement textAlignment="Center">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<group name="Country 2">
<groupExpression><![CDATA[$F{Country}]]></groupExpression>
<groupFooter>
<band height="20">
<textField>
<reportElement x="180" y="0" width="200" height="20" uuid="fb7c7dad-07c1-428d-873e-cb1eae0c00d7"/>
<textElement textAlignment="Center">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<detail>
<band height="30">
<textField>
<reportElement x="180" y="0" width="365" height="30" uuid="8edf2d40-c8e5-40d0-9bcd-3051581e7acb"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="170" height="30" uuid="4fa050bf-8bbb-47ce-8108-6e9ba25ac668"/>
<textFieldExpression><![CDATA[$F{ContactName}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

Related

How to add Ad Hoc database content to Textfield

I have an input parameter which is an ID.
I want to use a lookup table in the database to expand that ID into a long name for use in the report title.
How could I just add text into a textfield from a SQL query without needing to worry about rows of tabular data?
You can use the List component in the Title band. This List (or Table component) will be associated with another additional (non main) datasource for showing information (the Name by Id passed via Parameter in your case).
The main datasource will be used by Detail band (or another Table component with the its own datasource) for showing data filtered by parameter's value (Id in your case).
With help of textField's property isStretchWithOverflow (with true value) we can garantee that all text will be drawing with the textField.
The sample
In this sample I've used the DB distributed with the Jaspersoft Studio. The parameter addrId was used for filtering data by the id field of address table. This parameter was mapped to the List's datasource parameter with the same name (addrId). Yes, I've used the List component placed on Title band for showing information about the value of our external parameter (the city and the street of address in this sample). At the Detail band we are showing the information about documents (table document) related to our address (defined by addrId)
The report's template
<?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="growing_text" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="77f0cb04-7f4b-43dc-af12-89c25fa7c58c">
<subDataset name="dsAddrTitle" uuid="0eb7cd0c-f4f1-408d-be13-dc484fda80d5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<parameter name="addrId" class="java.lang.Integer"/>
<queryString>
<![CDATA[SELECT city + ', ' + street AS name FROM address WHERE id=$P{addrId}]]>
</queryString>
<field name="NAME" class="java.lang.String"/>
</subDataset>
<parameter name="addrId" class="java.lang.Integer">
<defaultValueExpression><![CDATA[33]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT ID, ADDRESSID, TOTAL FROM DOCUMENT WHERE ADDRESSID=$P{addrId} ORDER BY ADDRESSID]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="ADDRESSID" class="java.lang.Integer"/>
<field name="TOTAL" class="java.math.BigDecimal"/>
<title>
<band height="10" splitType="Stretch">
<componentElement>
<reportElement x="160" y="0" width="40" height="10" uuid="f4cb4e5c-e2d7-4927-b143-4cfcd7d99b76"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" ignoreWidth="true">
<datasetRun subDataset="dsAddrTitle" uuid="4bf3eb57-f752-4856-ac3a-fd7e3a33f434">
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<datasetParameter name="addrId">
<datasetParameterExpression><![CDATA[$P{addrId}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:listContents height="30" width="100">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="40" height="10" uuid="1b533c30-7868-450b-a5b9-59d5130dcb67"/>
<textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</title>
<columnHeader>
<band height="30">
<staticText>
<reportElement x="0" y="0" width="185" height="30" uuid="100faa3b-790d-4dc6-b86c-8911a8762207"/>
<text><![CDATA[ID]]></text>
</staticText>
<staticText>
<reportElement x="185" y="0" width="185" height="30" uuid="aef6af65-f7b5-42e9-a102-aeb272f99103"/>
<text><![CDATA[ADDRESSID]]></text>
</staticText>
<staticText>
<reportElement x="370" y="0" width="185" height="30" uuid="2c176a21-6387-4505-836e-7e250751755f"/>
<text><![CDATA[TOTAL]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="30" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="185" height="30" uuid="22cbe96d-5322-40e3-bd96-d2aa9bf35dd2"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="185" y="0" width="185" height="30" uuid="3adedcc9-f60e-4664-bbe8-6b7d7b8e13a4"/>
<textFieldExpression><![CDATA[$F{ADDRESSID}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00#">
<reportElement x="370" y="0" width="185" height="30" uuid="48041fd6-1375-4819-8ebb-ffd4aef84889"/>
<textFieldExpression><![CDATA[$F{TOTAL}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The output result

Jasper reports: positioning element on bottom of the page

I wonder if it's possible to position dynamically growing (table) element to the bottom of the page? My table element is on detail band, just above the page footer band.
Basically in my case the position of the topmost row of the table would be dynamically changing all the time based on the amount of rows in the table. But I'm not sure if creating this kind of presentation is even possible with Jasper where the table would be basically "growing" from bottom to top where the last row of the table would be basically fixed to the bottom of the page, just above page footer. There would be no problem if the position of the table's topmost row would be always fixed and table would "grow normally" from the fixed top position towards the bottom of the page...
I tried setting the table's position type property to Fix relative to bottom, but after that the whole table disappeared completely. This was the only thing I was able to think of so far to solve my issue.
Maybe the easiest way to achieve this is to put your table in a <groupFooter> with footerPosition="StackAtBottom"
The correct way to group depends on your datasource, but let assume you have just one table creating a dummy group.
Example of dummy group with table StackAtBottom of page
<?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="Example2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ca579c38-1e4f-4993-a020-efcea9d1096e">
<style name="table"><box><pen lineWidth="1.0" lineColor="#000000"/></box></style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF"><box><pen lineWidth="0.5" lineColor="#000000"/></box></style>
<subDataset name="Table" uuid="982be61b-ae46-4404-a9a0-30ba13e8c414">
<queryString language="xPath">
<![CDATA[/report/table/entry]]>
</queryString>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="class" class="java.lang.String">
<fieldDescription><![CDATA[class]]></fieldDescription>
</field>
</subDataset>
<queryString language="xPath">
<![CDATA[/report]]>
</queryString>
<group name="dummy" footerPosition="StackAtBottom">
<groupFooter>
<band height="29">
<componentElement>
<reportElement key="table" style="table" x="0" y="0" width="360" height="20" uuid="53ea5a0e-1218-4150-ab5a-5f947e73b284"/>
<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="Table" uuid="64092841-9993-4ccd-89b4-84a546c719cf">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("report/table/entry")]]></dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="4f5b1813-a9cc-4f83-9bdb-b0d8c4299133">
<jr:detailCell style="table_TD" height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="f1a97e19-e23d-40b6-ad95-10614f516db7"/>
<textFieldExpression><![CDATA[$F{class}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="98cfbe63-f865-419c-ad8f-d8af2ed706ba">
<jr:detailCell style="table_TD" height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="0480f047-02ba-4ec4-b12a-ef56a3cbfee9"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</groupFooter>
</group>
<detail>
<band height="17" splitType="Stretch"/>
</detail>
</jasperReport>
Result

iReport - Limit number of records allowed in a sub report

I am trying to create a report that will be used for check printing. Its layout is stub, stub, and then check. I thought the best way to do this would be have the detail for the stubs be a sub-report (inserted twice on the report) and the normal detail of the report for the check info. A 3rd party device will handle the "check" base on the info I pass in on the report in that detail band (printing account info for the micr part of the check, adding a signature and some anti theft "stuff").
The problem is I can't figure out how to limit the number of records on the sub-report. I have tried setting the height in the master for the band, in the master for the sub-report property, and on the sub-report for the height of the report. Nothing seemed to work. I also tried to do something like.
($V{REPORT_COUNT} %15) == 0
Now I am not a Java guy. We use jasper reports for form generation in or python based ERP system.
Any suggestions on how I should go about designing this report? Also to note the "check" part of the report would need to have void details on all pages except one.
Edit
For example, lets say that we pay vendor FOO for 35 invoices. The layout is going to be stub, stub, check (each a 1/3rd the size of the page). Stub 1 and stub 2 are identical copies of each other. So page one would show 15 invoices in stub one and then show the the SAME 15 invoices in the next stub, and then it would print the physical check details on the bottom 3rd of the page. Page 2 would show the next 15 invoices (same layout as above) but the check details are VOIDED. The last page will show the remaining 5 invoices.
The pages are perforated. We keep 1 stub, and then send the check stub to the vendor.
jrxml of master report
<?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="ap_checks" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3fb75d91-5293-4c89-8450-938a5ac37235">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/Users/pkraus/iReport/"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select
appay.id, appay.batch_id, appay.date, appay.payment_type_id, appay.vendor_id,appay.total,
appay.check_number,
vendors.code as vendor_code,vendors.name as vendor_name,
locations.name,locations.address_one,locations.address_two,locations.city,
states.code as state_code,locations.zip_code
from
ap_payments as appay,
ap_payment_types,
vendors,
locations,
states
where
appay.payment_type_id = ap_payment_types.id and
ap_payment_types.print_check = 't' and
vendors.id = appay.vendor_id and
locations.id = vendors.remit_to_id and
states.id = locations.state_id]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="batch_id" class="java.lang.Integer"/>
<field name="date" class="java.sql.Date"/>
<field name="payment_type_id" class="java.lang.Integer"/>
<field name="vendor_id" class="java.lang.Integer"/>
<field name="total" class="java.math.BigDecimal"/>
<field name="check_number" class="java.lang.String"/>
<field name="vendor_code" class="java.lang.String"/>
<field name="vendor_name" class="java.lang.String"/>
<field name="name" class="java.lang.String"/>
<field name="address_one" class="java.lang.String"/>
<field name="address_two" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state_code" class="java.lang.String"/>
<field name="zip_code" class="java.lang.String"/>
<detail>
<band height="200" splitType="Stretch">
<subreport isUsingCache="true" runToBottom="false">
<reportElement uuid="71baa8ec-c623-4032-a2b0-381776857ee6" x="0" y="0" width="572" height="152"/>
<subreportParameter name="check_id">
<subreportParameterExpression><![CDATA[$F{id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "ap_checks_stub.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="178"/>
<band height="163">
<textField>
<reportElement uuid="00182356-2626-4e23-90bf-c8ab35d9bd11" x="380" y="54" width="56" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{date}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="042dac2b-6fb5-401d-ab90-11c60cecfa98" x="17" y="114" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{address_one}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ec25e5af-5b4d-4f5a-8197-62a84e0b5773" x="17" y="125" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{address_two}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="37d3f097-e308-4601-9e1e-e21be81ad57a" x="17" y="134" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="9df87896-ea75-4411-aeb6-db0b1484d219" x="178" y="134" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{zip_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="d99d514e-893b-4b45-ae2b-b8677cee6ed9" x="98" y="134" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{state_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="926d835e-adc4-4f4b-a29f-5fa18d45090c" x="17" y="74" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{vendor_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6a8349b5-c86a-4ffc-87b7-84000ebef6af" x="17" y="105" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{vendor_name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ed874ea2-a95d-47cd-bf8e-b2b559a5dbbf" x="472" y="54" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{check_number}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
jrxml of sub report
<?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="ap_checks_stub" language="groovy" pageWidth="572" pageHeight="100" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="31589b1a-6d6a-40ff-870b-e84e52104956">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="check_id" class="java.lang.Number"/>
<queryString>
<![CDATA[select
pi.id as payment_id, pi.payment,
vi.number,vi.date,
ap_payments.check_number, vendors.code
from
payment_invoices as pi,
vendor_invoices as vi,
ap_payments,
vendors
where
vi.id = pi.invoice_id and
ap_payments.id = pi.check_id and
ap_payments.vendor_id = vendors.id and
pi.check_id = 1]]>
</queryString>
<field name="payment_id" class="java.lang.Integer"/>
<field name="payment" class="java.math.BigDecimal"/>
<field name="number" class="java.lang.String"/>
<field name="date" class="java.sql.Date"/>
<field name="check_number" class="java.lang.String"/>
<field name="code" class="java.lang.String"/>
<columnHeader>
<band height="24" splitType="Stretch">
<staticText>
<reportElement uuid="424923c4-ac9f-4763-919e-afe81870fb6f" x="0" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[number]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="28" splitType="Stretch">
<textField>
<reportElement uuid="4b06f8cf-15d3-44a3-9edf-31e5f760fac6" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{number}]]></textFieldExpression>
</textField>
<break>
<reportElement uuid="278dc135-0e6b-4d47-84bc-b3bf79c90edf" x="0" y="20" width="100" height="1">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} <= 15]]></printWhenExpression>
</reportElement>
</break>
<textField>
<reportElement uuid="80635d70-845f-4893-9f42-f13a064a255d" x="298" y="8" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="24" splitType="Stretch">
<textField>
<reportElement uuid="bc3035b9-7989-46a4-abf6-ff10ec486a60" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<lastPageFooter>
<band height="24">
<textField>
<reportElement uuid="3d6e71b0-7fb7-40ec-9e04-529f39003e71" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>
Try
$V{REPORT_COUNT} == 15+(($V{PAGE_NUMBER}-1)*15)
in the Print When Expression of the break in the subreport detail band.

Dynamically change width of element

I need to create table of contents in JasperReports.
I have already achieved this, but cant do anything with lines in TOC.
Currently they have a static width:
Chapter 1 ........ 2
Long Chapter Name ........ 3
End ........ 4
I want to stretch dotted lines to the width of the chapter name. Like here:
Chapter 1 ................. 2
Long Chapter Name ......... 3
End ....................... 4
How can I do this? Is there some 'padding' functionality in JR or should I create scriptlet for this task ? Thanks!
P.S. I'm using jasper reports 5.0.1
This wouldn't be a very neat way but I would draw many dots in your text box and hide the end using a frame to allow writing the number of the page.
<?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="table of content" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="df5894b6-0e62-4082-bdb8-3f0a1b26a2f4">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[SELECT
1 AS page,
'test' AS title
FROM
"account" account
Union
SELECT
4 AS page,
'chapter 2' AS title
FROM
"account" account
Union
SELECT
20 AS page,
'chapter 3: hello' AS title
FROM
"account" account]]>
</queryString>
<field name="page" class="java.lang.Integer"/>
<field name="title" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="20" splitType="Stretch">
<staticText>
<reportElement uuid="2e81fd32-3b8d-4b98-b96d-6409afb8d16f" x="0" y="0" width="555" height="20"/>
<textElement>
<font isBold="true" isStrikeThrough="false"/>
</textElement>
<text><![CDATA[Table of content]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="c8707508-946a-48ae-ae75-61810003e1db" x="0" y="0" width="555" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{title}+" .............................................................................................................................."]]></textFieldExpression>
</textField>
<frame>
<reportElement uuid="4040d203-6b49-4da2-8bcf-f3d6d48c7fd7" mode="Opaque" x="341" y="0" width="214" height="20"/>
</frame>
<textField>
<reportElement uuid="472f8f95-fdea-4cd9-b3a5-a1b9b66a8c44" mode="Opaque" x="321" y="0" width="20" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{page}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

Jasper Report graph in iReport repeating

I have a line graph in iReport which is incrementally repeating in every page, that is, if the graph has 30 x/y pairs (this is dynamic), the report will have 30 pages, of which the first will have just one value, the 2nd two values, and so on. Only the last one will contain the complete graph.
Questions "chart repeat many time" and "Problem with charting using JasperReport" and "How to print the grand total only in the last page of a very long report?" did not solve my problem. I understand that putting the chart in the Detail section makes the chart repeat, but putting it in the Summary, Footer, lastPageFooter, Title, etc. sections makes it display only one value. Same when I put it in the Detail section and use <printWhenExpression>.
My code:
<?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="nodes-allarmipersistenti" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="day" class="java.lang.Number"/>
<field name="month" class="java.lang.String"/>
<field name="year" class="java.lang.String"/>
<field name="dsunita" class="java.lang.String"/>
<field name="valueNumber" class="java.lang.Number"/>
<field name="logo" class="java.lang.String"/>
<field name="today" class="java.lang.String"/>
<field name="option" class="java.lang.String"/>
<title>
<band height="89">
<staticText>
<reportElement mode="Opaque" x="0" y="67" width="424" height="22" backcolor="#CCFFFF"/>
<textElement textAlignment="Right" verticalAlignment="Middle" markup="none">
<font size="10" isBold="true" pdfFontName="Helvetica-Bold" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[GRAFICO PARAMETRO]]></text>
</staticText>
<staticText>
<reportElement x="600" y="0" width="100" height="38"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Stampato in data]]></text>
</staticText>
<textField>
<reportElement x="700" y="0" width="102" height="38"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{today}]]></textFieldExpression>
</textField>
<image>
<reportElement x="0" y="0" width="100" height="67"/>
<imageExpression><![CDATA[$F{logo}]]></imageExpression>
</image>
<staticText>
<reportElement x="700" y="38" width="102" height="29"/>
<textElement textAlignment="Right"/>
<text><![CDATA[MaRe - Telecontrollo]]></text>
</staticText>
<textField>
<reportElement mode="Opaque" x="424" y="67" width="378" height="22" backcolor="#CCFFFF"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[' ' + $F{option}]]></textFieldExpression>
</textField>
</band>
</title>
<lastPageFooter>
<band height="387" splitType="Stretch">
<xyLineChart>
<chart evaluationTime="Page">
<reportElement x="0" y="0" width="802" height="387"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<xyDataset>
<dataset incrementType="Report"/>
<xySeries>
<seriesExpression><![CDATA["Unità " + $F{dsunita}]]></seriesExpression>
<xValueExpression><![CDATA[$F{day}]]></xValueExpression>
<yValueExpression><![CDATA[$F{valueNumber}]]></yValueExpression>
</xySeries>
</xyDataset>
<linePlot>
<plot/>
</linePlot>
</xyLineChart>
</band>
</lastPageFooter>
</jasperReport>
Datasource here is a JRBeanCollectionDataSource.
Putting it in the Detail band is wrong (as you noticed). Putting it in the Title or Summary will work. Your choice of evaluationTime="Page" doesn't look right. Try changing this to evaluationTime="Report"