Jump to content
Changes to the Jaspersoft community edition download ×

Dynamic content in a static text field in JRXML file


pallavig026

Recommended Posts

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>

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 ?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...