Jump to content
Changes to the Jaspersoft community edition download ×

I need 2 different evalution_times in one field


Hauptlorenz

Recommended Posts

Hello out there,

 

I have one text field, containing this:

"Page "+$V{PAGE_NUMBER}+" / + $V{PAGE_NUMBER}

(I want to use one growing field)

 

For the second part I need evaluation time "report" and the first one must be "now".

 

How can I do this for generating normal output like

"Page 1 / 2"

"Page 2 / 2"

aso.

 

 

Thank you very much.

Frank

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

If you use JR >= 1.2.0, you can achieve this via the "Auto" evaluation type. The "Auto" evaluation type was introduced to support text field expressions which need to be evaluated at more than one moment (and this is your case).

 

You need to create a helper variable that copies the PAGE_NUMBER value but has Page reset type so that it will get evaluated at page time (the "Auto" evalution type uses the reset type of variables to determine when to evaluate them).

 

This is what you need to do:

Code:

<variable name="CurrPageNo" class="java.lang.Integer" resetType="Page">
<variableExpression>$V{PAGE_NUMBER}</variableExpression>
</variable>
..
<textField evaluationTime="Auto">
..
<textFieldExpression><![CDATA["Page " + $V{CurrPageNo} + " / " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>

 

HTH,

Lucian

Link to comment
Share on other sites

<textElement> allows to set the text alignment via the attribute textAlignment, in <box> you can use the padding* attributes to control the space between the border of the text field and the text.

 

I don't like the Auto-feature, it spreads information about the evalution time of a text field to several locations in the JRXML. It is a potenzial source for problems, which are easy to introduce, but hard to find, especially if your are not the initial designer.

Link to comment
Share on other sites

Hello,

 

I've gone the way with the "auto"-feature.

This was also the way I thought on myself (variables)

but I did not find an evaluation param on the variables.

Would this not be the better way?

 

The other way, I haven't really understood.

You mean, I can order Textfields in a table-like order

without specifying coords but paddings between the

elements? How?

 

Best regards,

Frank

 

PS: I'm using JasperReports since yesterday and it's running through a PHP WebPortal in the background via

a Shell/Java-Bridge. Works very well!

Link to comment
Share on other sites

Sorry, some misunderstanding. You must set the position of the text field. You can influence the padding and alignment of a text in a textField element:

 

Code:
<textField>
<reportElement x="0" y="0" width="100" height="50"/>
<box padding="0" />
<textElement textAlignment="Right" />
<textFieldExpression>
<![CDATA["foobar"]]>
</textFieldExpression>
</textField>

 

But these values do not influence the padding or alignment of the text field related to the surrounding band.

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...