Print When Expression

Hi all

Using 'Print When Expression' I'm looking to do two things

1. When a field value is above a certain value .. do not print ie somthing like


$F{myVal} <=100 then print value else do not print


2.Always hide a field

I tried Boolean (true) but an error

as you may guess I'm not a java man

Thanks for the help
gr4nt4's picture
148
Joined: May 24 2007 - 2:36am
Last seen: 16 years 4 months ago

5 Answers:

Try
Code:
Boolean.valueOf($F{myVal}.intValue() <= 100)</td></tr></tbody></table><br />
and<br />
<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre>Boolean.TRUE</td></tr></tbody></table><br />
<br />
If you're not literate in Java you could try using the Groovy or BeanShell compilers as you'd be able to use a simpler syntax.<br />
<br />
HTH,<br />
Lucian
lucianc's picture
87143
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 1 min ago
Yep that got it many thanks, I'll also take a look at groovy
gr4nt4's picture
148
Joined: May 24 2007 - 2:36am
Last seen: 16 years 4 months ago
Hi All

I find this really strange. I am using Java 5. In java 5 Boolean and boolean are both allowed and dont need to be casted. According to jasperreports, the printWhen expression must contain valid Java code and must return a boolean. Then why on earth must the print when expression generate Boolean and not boolean. For example:

$F{FieldName} != null (Mot allowed)
new Boolean($F{FieldName} != null) (Is allowed)

That is really strange behavior because in Java 5 it would be

$F{FieldName} != null (Is allowed)
new Boolean($F{FieldName} != null) (Is allowed)

Could someone explaing this please?
martynhiemstra's picture
Joined: Jan 25 2007 - 4:31pm
Last seen: 16 years 8 months ago
If you use the JDT-base compiler, you need to instruct it to compile 1.5 code. You can read how to do that [url=http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=&func....

HTH,
Lucian
lucianc's picture
87143
Joined: Jul 17 2006 - 1:10am
Last seen: 19 hours 1 min ago
Hi Lucianc

Thanks for your quick response. In short for those of you who dont want to follow the link:

To compile Java 1.5 code with this compiler, you might need to explicitly set the following properties in your jasperreports.properties file:

Code:
<br />
org.eclipse.jdt.core.compiler.source=1.5<br />
org.eclipse.jdt.core.compiler.compliance=1.5<br />
org.eclipse.jdt.core.compiler.codegen.TargetPlatform=1.5<br />
</td></tr></tbody></table>
martynhiemstra's picture
Joined: Jan 25 2007 - 4:31pm
Last seen: 16 years 8 months ago
Feedback