<p>Can somebody tell me how to use the <em><code>printWhenExpression</code></em> of JasperReports?</p>

Do you have an error relative to boolean ?
Because you need to use Boolean instead of the primitive type.
So:
```
```
$F{mesure} != "PH"
($F{userfd4}).equals("1") ? true : false
```
```
would give
```
cannot cast from boolean to Boolean
```
.
```
```
( $F{mesure}.startsWith("PH") ? Boolean.TRUE:Boolean.FALSE ) 
($F{userfd4}).equals("1") ? Boolean.TRUE : Boolean.FALSE
```
```
would be correct.
See also this
example
Update Nov 2015 (7 years later)
Petter Friberg
points out
in the comments
:
In
jasper report
6.0 this is not need:
You can return either
```
boolean
```
or
```
Boolean
```
a simple expression like
```
$F{fieldName}.equals("hello")
```
will work.
You can see a demo of that command in
```
demo/samples/tableofcontents/reports/TocPart.jrxml
```
```
```
<reportElement style="Sans_Bold" positionType="Float" x="50" y="0" width="100" height="15" isRemoveLineWhenBlank="true" uuid="db8b68c6-4430-4199-8967-3ab5c077cb56">
    <property name="local_mesure_unitx" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.x" value="px"/>
    <printWhenExpression><![CDATA[$F{level} == 1]]></printWhenExpression>
</reportElement>
```
```