Jump to content

Variable execution order


tkilshaw_1

Recommended Posts

I am using TIBCO Jaspersoft® Studio 6.11.0 - Visual Designer for JasperReports 6.11.0. on Windows 10.

I have a simple one page report. It has a single <detail> element which contains a single <band> element.

If I create a variable - call it v1- and then drop that on my form and run it, it works fine.

If I create a variable - v2 - and then use that in the expression for v1, v1 produces null.

When I go to the source I see that v2 comes after v1.

If I move v2 before v1 in the source then v1 works as expected.

When placed on a form all variables have an Evaluation Time of "Now". I have tried some of the other evaluation times but they make no difference.

If a variable uses another variable, that other variable will be of use only if it has a value. If my variables use other variables in their expressions it will be a real challenge on a complex form to ensure correct evaluation order.

Is this a known problem in Jasper? Nothing I have seen in the documentation or online talks about this.

Am I doing something wrong? Is there a workaround?

any help greatly appreciated,

Terry

 

 


Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 weeks later...

See Source code below: V1= $VPage  V2=V1      Added 1 in the textbox for visual

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1b423b67-c8b9-4256-9132-e680bbdfdeac">
    <queryString>
        <![CDATA[]]>
    </queryString>
    <variable name="Variable_1" class="java.lang.Integer">
        <variableExpression><![CDATA[$V{PAGE_NUMBER}]]></variableExpression>
    </variable>
    <variable name="Variable_2" class="java.lang.Integer">
        <variableExpression><![CDATA[$V{Variable_1}]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="30" splitType="Stretch">
            <textField>
                <reportElement x="50" y="0" width="100" height="30" uuid="0fd880cc-44e2-4aeb-b4d7-dc16c75006c0"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement x="197" y="0" width="100" height="30" uuid="7f39fd74-e747-4d89-9ec4-e3c9fd8737f0"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{Variable_1}+1]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement x="401" y="0" width="100" height="30" uuid="ba244951-d773-4295-aab3-5648c80340d8"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{Variable_2}+2]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>
 

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