grototo Posted May 2, 2019 Share Posted May 2, 2019 Hi folks,worried about something that should be easy.Got a Java Bean called Psuite :public class Poursuite extends BaseBean{.... private Date dateIntegrationCreation;....}[/code] Got another Java Bean called ActePratiquepublic class ActePratique extends BaseBean{....private Date dateSignification;...}[/code]Finally got some technical bean including those beans :public class ActePratiquePourP750 extends BaseBean{.... private Poursuite laPoursuite; private List<ActePratique> lesActePratique;...}[/code] I'm passing a java bean collection of type ActePratiquePourP750 to a subreport.Then I'm using each Poursuite, and creating a new dataset of ActePratique and print them as a list. My issue is that I need to calculate the number of days between dateSignification and dateIntegrationCreation.I'm doing fine with the computing problem (something like new Integer((int) ( ($P{dateIntegrationPsuite}.getTime() - $F{dateSignification}.getTime()) / (1000*60*60*24) )), but how to pass dateIntegrationCreation to the list?Shall I use a parameter? A variable?Here is the jrxml file I'm using so far :<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.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="p750liste" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b1e34fe7-a7d3-4396-9cf0-cad1ab9ffded"> <import value="net.sf.jasperreports.engine.*"/> <import value="java.util.*"/> <import value="net.sf.jasperreports.engine.data.*"/> <subDataset name="listeActes" uuid="55d8bb83-abff-48f7-94e0-dd312709f1ba"> <parameter name="dateIntegrationPsuite" class="java.util.Date"/> <queryString> <![CDATA[]]> </queryString> <field name="leTypeActePratiqueReferentiel" class="myproject.bean.referentiel.TypeActePratiqueReferentiel"> <fieldDescription><![CDATA[leTypeActePratiqueReferentiel]]></fieldDescription> </field> <field name="deboursTresor" class="java.math.BigDecimal"> <fieldDescription><![CDATA[deboursTresor]]></fieldDescription> </field> <field name="dateSignification" class="java.util.Date"> <fieldDescription><![CDATA[dateSignification]]></fieldDescription> </field> <variable name="dateIntegrationPsuite" class="java.util.Date"> <initialValueExpression><![CDATA[$V{dateIntegrationPsuite}]]></initialValueExpression> </variable> </subDataset> <queryString> <![CDATA[]]> </queryString> <field name="laPoursuite" class="myproject.bean.poursuite.Poursuite"> <fieldDescription><![CDATA[laPoursuite]]></fieldDescription> </field> <field name="leRedeVable" class="myproject.bean.redevable.Redevable"> <fieldDescription><![CDATA[leRedeVable]]></fieldDescription> </field> <field name="lesActePratique" class="java.util.List"> <fieldDescription><![CDATA[lesActePratique]]></fieldDescription> </field> <variable name="dateIntegrationPsuite" class="java.util.Date" resetType="Group" resetGroup="gpredetpsuite"> <initialValueExpression><![CDATA[$F{laPoursuite}.getDateIntegrationCreation()]]></initialValueExpression> </variable> <group name="gpredetpsuite" keepTogether="true"> <groupExpression><![CDATA[$F{leRedeVable}.getNomOuDenominationSociale()+$F{laPoursuite}.getRef1Affaire()]]></groupExpression> <groupHeader> <band splitType="Prevent"/> </groupHeader> <groupFooter> <band height="10" splitType="Prevent"> <frame> <reportElement x="0" y="0" width="740" height="10" uuid="9a75822b-bf1a-4d21-adc0-20229e1174e3"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> </frame> </band> </groupFooter> </group> <pageHeader> <band height="41"> <frame> <reportElement x="0" y="0" width="140" height="40" uuid="c79e2684-384b-4304-835b-3a739fc44647"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="140" height="40" uuid="db285274-2584-47fb-b22d-e27c17ad56c2"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Nom Redevable]]></text> </staticText> </frame> <frame> <reportElement x="140" y="0" width="200" height="40" uuid="060fddb8-20dc-49fc-b284-e29fab9860c0"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="200" height="40" uuid="4f9491f8-3d96-4a78-9732-73e923df19d6"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Réf psuite]]></text> </staticText> </frame> <frame> <reportElement x="340" y="0" width="120" height="40" uuid="740c0c32-e1d1-4470-9f93-ebbc261e283d"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="120" height="40" uuid="07c0c99a-8c01-49da-9ec8-d0a6c550d520"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Acte pratiqué]]></text> </staticText> </frame> <frame> <reportElement x="461" y="1" width="120" height="40" uuid="4b03512b-c2f4-4e89-9215-ce3e3227973d"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="119" height="40" uuid="2bafe7e2-fd98-46d8-99a2-1e20ce7d6fd0"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Débours Trésor]]></text> </staticText> </frame> </band> </pageHeader> <detail> <band height="40" splitType="Prevent"> <frame> <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="140" height="40" uuid="8eb713b5-59b3-426b-8fe7-b2c27cbec398"/> <box> <topPen lineWidth="0.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> </box> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="0" y="0" width="140" height="40" uuid="f2f65c0f-a0d4-4b9b-bca4-07cd72239d9d"/> <textFieldExpression><![CDATA[$F{leRedeVable}.getNomOuDenominationSociale()]]></textFieldExpression> </textField> </frame> <frame> <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="140" y="0" width="200" height="40" uuid="f745a754-8416-4cd7-86dc-79ad5537084b"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> </box> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="200" height="40" uuid="00fff0b8-7032-41aa-afdf-121251ddf569"/> <textFieldExpression><![CDATA[$F{laPoursuite}.getRef1Affaire()]]></textFieldExpression> </textField> </frame> <componentElement> <reportElement positionType="Float" x="340" y="0" width="360" height="40" isPrintWhenDetailOverflows="true" uuid="9d38982d-e7d4-45ef-a976-0e607d8fdd57"> <property name="net.sf.jasperreports.export.headertoolbar.table.name" value="listeeee"/> </reportElement> <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" printOrder="Vertical"> <datasetRun subDataset="listeActes" uuid="71f1ef40-d124-431a-b574-b26b4af0f7c4"> <datasetParameter name="REPORT_PARAMETERS_MAP"> <datasetParameterExpression><![CDATA[]]></datasetParameterExpression> </datasetParameter> <dataSourceExpression><![CDATA[new JRBeanCollectionDataSource($F{lesActePratique})]]></dataSourceExpression> </datasetRun> <jr:listContents height="40" width="360"> <frame> <reportElement x="0" y="0" width="121" height="40" uuid="a99d8961-5a82-4a2c-90b9-37f2ed1de49d"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> </box> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement x="0" y="0" width="120" height="40" uuid="60e779f0-5712-43a5-b48f-9cd2855b1487"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$F{leTypeActePratiqueReferentiel}.getCodeReferentielThemis()]]></textFieldExpression> </textField> </frame> <frame> <reportElement x="121" y="0" width="121" height="40" uuid="750d5812-8a26-4f06-8609-9008c29c60d9"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> <rightPen lineWidth="1.0"/> </box> <textField isStretchWithOverflow="true" pattern="#,##0.##¤;#,##0.## ¤" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="121" height="40" uuid="212658f7-08b8-4749-a81f-937498f6c403"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$F{deboursTresor}]]></textFieldExpression> </textField> </frame> <frame> <reportElement x="242" y="0" width="118" height="40" uuid="f0c31cba-676a-4e26-a75e-9cc6d743ddcf"/> <textField isBlankWhenNull="true"> <reportElement mode="Opaque" x="0" y="0" width="118" height="40" backcolor="#C1ADD9" uuid="0b8a98a6-500b-481a-ad8d-cbc368c7bfb1"/> <textFieldExpression><![CDATA[new Integer((int) ( ($P{dateIntegrationPsuite}.getTime() - $F{dateSignification}.getTime()) / (1000*60*60*24) ))]]></textFieldExpression> </textField> </frame> </jr:listContents> </jr:list> </componentElement> </band> </detail></jasperReport>[/code]Thanks for your help.Regards,Thomas Link to comment Share on other sites More sharing options...
grototo Posted May 2, 2019 Author Share Posted May 2, 2019 Sorry, finally got it....was using a wrong syntax:((((<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.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="p750liste" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b1e34fe7-a7d3-4396-9cf0-cad1ab9ffded"> <import value="net.sf.jasperreports.engine.*"/> <import value="java.util.*"/> <import value="net.sf.jasperreports.engine.data.*"/> <subDataset name="listeActes" uuid="55d8bb83-abff-48f7-94e0-dd312709f1ba"> <parameter name="dateIntegrationPsuite" class="java.util.Date"/> <queryString> <![CDATA[]]> </queryString> <field name="leTypeActePratiqueReferentiel" class="myproject.bean.referentiel.TypeActePratiqueReferentiel"> <fieldDescription><![CDATA[leTypeActePratiqueReferentiel]]></fieldDescription> </field> <field name="deboursTresor" class="java.math.BigDecimal"> <fieldDescription><![CDATA[deboursTresor]]></fieldDescription> </field> <field name="dateSignification" class="java.util.Date"> <fieldDescription><![CDATA[dateSignification]]></fieldDescription> </field> <variable name="dateIntegrationPsuite" class="java.util.Date"> <initialValueExpression><![CDATA[$V{dateIntegrationPsuite}]]></initialValueExpression> </variable> </subDataset> <parameter name="dateIntegrationPsuite" class="java.util.Date" isForPrompting="false"> <defaultValueExpression><![CDATA[$F{laPoursuite}.getDateIntegrationCreation()]]></defaultValueExpression> </parameter> <queryString> <![CDATA[]]> </queryString> <field name="laPoursuite" class="myproject.bean.poursuite.Poursuite"> <fieldDescription><![CDATA[laPoursuite]]></fieldDescription> </field> <field name="leRedeVable" class="myproject.bean.redevable.Redevable"> <fieldDescription><![CDATA[leRedeVable]]></fieldDescription> </field> <field name="lesActePratique" class="java.util.List"> <fieldDescription><![CDATA[lesActePratique]]></fieldDescription> </field> <group name="gpredetpsuite" keepTogether="true"> <groupExpression><![CDATA[$F{leRedeVable}.getNomOuDenominationSociale()+$F{laPoursuite}.getRef1Affaire()]]></groupExpression> <groupHeader> <band splitType="Prevent"/> </groupHeader> <groupFooter> <band height="10" splitType="Prevent"> <frame> <reportElement x="0" y="0" width="771" height="10" uuid="9a75822b-bf1a-4d21-adc0-20229e1174e3"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> </frame> </band> </groupFooter> </group> <pageHeader> <band height="41"> <frame> <reportElement x="0" y="0" width="140" height="40" uuid="c79e2684-384b-4304-835b-3a739fc44647"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="140" height="40" uuid="db285274-2584-47fb-b22d-e27c17ad56c2"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Nom Redevable]]></text> </staticText> </frame> <frame> <reportElement x="140" y="0" width="140" height="40" uuid="060fddb8-20dc-49fc-b284-e29fab9860c0"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="140" height="40" uuid="4f9491f8-3d96-4a78-9732-73e923df19d6"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Réf psuite]]></text> </staticText> </frame> <frame> <reportElement x="281" y="0" width="120" height="40" uuid="740c0c32-e1d1-4470-9f93-ebbc261e283d"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> </box> <staticText> <reportElement x="0" y="0" width="120" height="40" uuid="07c0c99a-8c01-49da-9ec8-d0a6c550d520"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Acte pratiqué]]></text> </staticText> </frame> <frame> <reportElement x="401" y="0" width="120" height="40" uuid="4b03512b-c2f4-4e89-9215-ce3e3227973d"/> <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> <staticText> <reportElement x="1" y="1" width="119" height="40" uuid="2bafe7e2-fd98-46d8-99a2-1e20ce7d6fd0"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Débours Trésor]]></text> </staticText> </frame> </band> </pageHeader> <detail> <band height="40" splitType="Prevent"> <frame> <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="140" height="40" uuid="8eb713b5-59b3-426b-8fe7-b2c27cbec398"/> <box> <topPen lineWidth="0.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> </box> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="0" y="0" width="140" height="40" uuid="f2f65c0f-a0d4-4b9b-bca4-07cd72239d9d"/> <textFieldExpression><![CDATA[$F{leRedeVable}.getNomOuDenominationSociale()]]></textFieldExpression> </textField> </frame> <frame> <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="140" y="0" width="140" height="40" uuid="f745a754-8416-4cd7-86dc-79ad5537084b"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> </box> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="140" height="40" uuid="00fff0b8-7032-41aa-afdf-121251ddf569"/> <textFieldExpression><![CDATA[$F{laPoursuite}.getRef1Affaire()]]></textFieldExpression> </textField> </frame> <componentElement> <reportElement positionType="Float" x="281" y="0" width="490" height="40" isPrintWhenDetailOverflows="true" uuid="9d38982d-e7d4-45ef-a976-0e607d8fdd57"> <property name="net.sf.jasperreports.export.headertoolbar.table.name" value="listeeee"/> </reportElement> <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" printOrder="Vertical"> <datasetRun subDataset="listeActes" uuid="be36d58b-205f-4e4f-b938-b8833773b442"> <datasetParameter name="REPORT_PARAMETERS_MAP"> <datasetParameterExpression><![CDATA[]]></datasetParameterExpression> </datasetParameter> <datasetParameter name="dateIntegrationPsuite"> <datasetParameterExpression><![CDATA[$F{laPoursuite}.getDateIntegrationCreation()]]></datasetParameterExpression> </datasetParameter> <dataSourceExpression><![CDATA[new JRBeanCollectionDataSource($F{lesActePratique})]]></dataSourceExpression> </datasetRun> <jr:listContents height="40" width="490"> <frame> <reportElement x="0" y="0" width="121" height="40" uuid="a99d8961-5a82-4a2c-90b9-37f2ed1de49d"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> </box> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement x="0" y="0" width="120" height="40" uuid="60e779f0-5712-43a5-b48f-9cd2855b1487"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$F{leTypeActePratiqueReferentiel}.getCodeReferentielThemis()]]></textFieldExpression> </textField> </frame> <frame> <reportElement x="121" y="0" width="121" height="40" uuid="750d5812-8a26-4f06-8609-9008c29c60d9"/> <box> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="0.0"/> <rightPen lineWidth="1.0"/> </box> <textField isStretchWithOverflow="true" pattern="#,##0.##¤;#,##0.## ¤" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="121" height="40" uuid="212658f7-08b8-4749-a81f-937498f6c403"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$F{deboursTresor}]]></textFieldExpression> </textField> </frame> <frame> <reportElement x="242" y="0" width="118" height="40" uuid="f0c31cba-676a-4e26-a75e-9cc6d743ddcf"/> <textField isBlankWhenNull="true"> <reportElement mode="Opaque" x="0" y="0" width="118" height="40" backcolor="#C1ADD9" uuid="0b8a98a6-500b-481a-ad8d-cbc368c7bfb1"/> <textFieldExpression><![CDATA[new Integer((int) ( ( $F{dateSignification}.getTime() -$P{dateIntegrationPsuite}.getTime()) / (1000*60*60*24) ))]]></textFieldExpression> </textField> </frame> <textField pattern="dd/MM/yyyy"> <reportElement x="360" y="0" width="130" height="20" uuid="97c2f251-1507-4dd8-80df-1fc672d3ce48"/> <textFieldExpression><![CDATA[$P{dateIntegrationPsuite}]]></textFieldExpression> </textField> <textField pattern="dd/MM/yyyy"> <reportElement x="360" y="20" width="130" height="20" uuid="6e5b150c-6707-46e7-9aac-f76f0a51abea"/> <textFieldExpression><![CDATA[$F{dateSignification}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail></jasperReport> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now