Dynamic content in a static text field in JRXML file

0

Hi,

Each month we need to change the date in JRXML file manually as 14.11,14,12 etc.

How can i automate this feature? Like code will read the current system date, once it reaches 14th of the month , automatically the date will change in jrxml file as well?

Please help.

Below is the code snippet

<staticText>

            <reportElement key="staticText-2" mode="Opaque" x="381" y="242" width="79" height="18" forecolor="#000000" backcolor="#FFFFFF" uuid="4ec23e25-c8d9-4941-bd81-777aff6c08a7"/>

<box>

                                   <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>

                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>

                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>

                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/>

                        </box>

                        <textElement textAlignment="Left" verticalAlignment="Top" rotation="None">

                        <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>

                        <paragraph lineSpacing="Single"/>

                        </textElement>

            <text><![CDATA[14.01.2019]]></text>    ----->>>> This should be automated. The date should change according to the system date. Every month once the date hits 14 it should change in file too. 

            </staticText>

pallavig026's picture
Joined: Oct 17 2018 - 12:16am
Last seen: 1 year 7 months ago

Hi Again,

I have changed the static field to dynamic field like below.

<textField>

                        <reportElement key="staticText-2" mode="Opaque" x="381" y="242" width="79" height="18" forecolor="#000000" backcolor="#FFFFFF" uuid="f6141550-bf19-4cf2-be66-ba676a3be639"/>

                        <box>

<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>

                              <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>

                              <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>

                              <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/>

                        </box>

                        <textElement textAlignment="Left" verticalAlignment="Top" rotation="None">

                              <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>

                              <paragraph lineSpacing="Single"/>

                        </textElement>

                        <textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yy").format(new Date())]]></textFieldExpression>

                  </textField>

But my report will run on every month end, So after the month completed report should show next month 14 as date. can you please help ?

pallavig026 - 1 year 8 months ago

Hi, Thank you so much for the answer. But when i tried to execute this code its showing the date as "14/12/2018". But i want to show next month date. Like current month is Jan , so i should display 14.02.2019. Requirement is: From Jan 1 to Jan 30 the date should display as Feb 14 (14.02.2019), And for Feb1 to Feb 28  the date should display as 14.03.2019. Its like for the current month we should display next month 14.mm.yyyy as the date.

pallavig026 - 1 year 8 months ago

Hi Again, Requirement got changed from client side. I need to use the "accounting date " field in the report (which is nothing but the current date). And that parameter is declared as follows: <parameter name="AccountingDate" class="java.sql.Timestamp" isForPrompting="false">
        <defaultValueExpression><![CDATA[bdw.reportmanager.HPDFormatter.getTimestamp("2006", "1", "31")]]></defaultValueExpression>
    </parameter>   So how can i make use this "Accounting date" and display next month date? NOTE: accounting date is nothing but the current date. IT would be great if u can please help. Thank you 

pallavig026 - 1 year 8 months ago

1 Answer:

1

Linking this question to the same one on stackoverflow:

https://stackoverflow.com/questions/54104693/dynamic-content-in-text-fie...

narcism's picture
1255
Joined: Nov 22 2010 - 12:39am
Last seen: 4 hours 11 min ago
Feedback