JRXML - Display a checkbox in a table

Hal picture Hal · Jun 21, 2011 · Viewed 14k times · Source

I can't manage to display a checkbox in a table in jrxml.

Here is a sample of my code:

<detail>
    <band height="45" splitType="Stretch">
        <textField isBlankWhenNull="true">
            <reportElement style="MyCustomStyle" stretchType="RelativeToTallestObject" x="650" y="0" width="80" height="35"/>
            <textElement textAlignment="Center"/>
            <textFieldExpression class="java.lang.Boolean"><![CDATA[$F{myBooleanVariable}]]>
            </textFieldExpression>
        </textField>
    </band>
</detail>

The column just displays true or false. I supposed that specifying class="java.lang.Boolean" in the textFieldExpression element would convert the value to a checkbox but apparently, I need more than that.

Any idea of what I'm doing wrong?

Answer

Spoonaroony picture Spoonaroony · Aug 6, 2013

I just added some unicode to the solution you already made:

<textFieldExpression><![CDATA[$F{myBooleanVairiable}? "\u2713":"\u2717"]]></textFieldExpression>

u2713 translates to a tick mark and u2717 to a cross

Remember to make sure you're encoding statement at the top of your xml page is set to UTF8: