Question

I am trying to use BIRT 2.5.0 to generate a pdf file. BIRT is called from pHp (this is done thanks to JavaBridge and a Tomcat server).

And I am simply trying to create a checkbox, checked under certain conditions. I looked a bit on the internet and found 2 different ways to do it.

The first way is to play with the Visibility if the field "idclassebillet" (on which I am making the test) has a value of 1. I did it this way :

<image id="9010">
    <list-property name="visibility">
        <structure>
            <property name="format">all</property>
            <expression name="valueExpr" type="javascript">row["classEq1"]</expression>
        </structure>
    </list-property>
    <list-property name="boundDataColumns">
        <structure>
            <property name="name">classEq1</property>
            <text-property name="displayName">classEq1</text-property>
            <expression name="expression" type="javascript">dataSetRow["idclassebillet"] == 1</expression>
            <property name="dataType">boolean</property>
        </structure>
    </list-property>
    <property name="source">embed</property>
    <property name="imageName">checkbox_unchecked.png</property>
</image>

But this doesn't work.

So the second solution that I found was to play with a simple URL. This solution is much more convenient, but doesn't work neither. This would looks like that.

<image id="9018">
    <property name="source">url</property>
    <list-property name="boundDataColumns">
        <structure>
            <property name="name">classEq1</property>
                <text-property name="displayName">classEq1</text-property>
                <expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
            <property name="dataType">integer</property>
        </structure>
    </list-property>
    <expression name="uri" type="javascript">
        if(row["classEq1"] == 1)
            "http://my.server.com/checkbox_checked.png"+row["classEq1"];
        else
            "http://my.server.com/checkbox_unchecked.png"+row["classEq1"];
    </expression>
</image>

In both cases, I declare the field "dataSetRow["idfield"]" like that :

<data-sets>
    <oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="infoBordereau" id="178">
        <structure name="cachedMetaData">
            <list-property name="resultSet">
            ...
                <structure>
                    <property name="position">9</property>
                    <property name="name">idclassebillet</property>
                    <property name="dataType">integer</property>
                </structure>
            ...
        </structure>
        <property name="dataSource">GestionBillet</property>
        <list-property name="resultSet">
            ...
            <structure>
                <property name="position">8</property>
                <property name="name">idclassebillet</property>
                <property name="nativeName">idclassebillet</property>
                <property name="dataType">integer</property>
            </structure>
            ...
        </list-property>
    ....
    </oda-data-set>
</data-sets>

I checked that I can access to the content of "idclassebillet". If I simply print it this way, it works fine :

<data id="90060001">
    <property name="whiteSpace">nowrap</property>
    <property name="dataSet">infoBordereau</property>
    <list-property name="boundDataColumns">
        <structure>
            <property name="name">classEq1</property>
            <text-property name="displayName">classEq1</text-property>
            <expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
            <property name="dataType">integer</property>
        </structure>
    </list-property>
    <property name="resultSetColumn">classEq1</property>
</data>

And whatever the solution I choose to get my "dynamic" images, I always get the same image, whatever the value of "dataSetRow["idclassebillet"]" is. I have no problem accessing and printing the image. The problem is more to "test" the value of the "idclassebillet" field (ie. how can I access this field ?).

I hope that you understand what I am trying to do. If you have a better solution (and if possible an example of working code), don't hesitate to share ^^ :)

Many thanks,

Raphaël POITTEVIN

NB : At first, I wanted my images to be embedded in the document (this what I use in the first solution), but as this didn't worked, I used an images hosted on http://my.server.com ...

Was it helpful?

Solution

If your objective is to display an unchecked/checked checkbox, have you considered using the Wingdings font with characters 0xA8 and 0xFD or 0xFE?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top