Reference 1 parameter in another?

Hi there,

Is there anyway to ensure the order in which parameters are evaluated?  I have 2 parameters (e.g.) and 1 refers to the other and is a substring of that first parameter.  Sometimes though, param2 is null, sometimes it has a value taken from Param1.  Just wondering how I can enforce P1 is always evaluated before P2?

You can run the below source with Parameter1 being test1,test2,test3 repeatedly to see what I mean.  Sometimes Parameter2 will be null, sometimes it will be "test1".


Sample source:

<jasperReport xmlns="" xmlns:xsi="" xsi:schemaLocation="" name="sample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d9385bae-2cc3-433e-bf49-27d6a50e3d62">
    <property name="" value="One Empty Record"/>
    <parameter name="Parameter1" class="java.lang.String"/>
    <parameter name="Parameter2" class="java.lang.String">
        <defaultValueExpression><![CDATA[$P{Parameter1}.indexOf(",") > 0?$P{Parameter1}.substring(0, $P{Parameter1}.indexOf(",")):$P{Parameter1}]]></defaultValueExpression>
        <band height="125" splitType="Stretch">
                <reportElement x="120" y="10" width="278" height="30" uuid="924e8f84-e48b-4975-af13-c90b4b5973cf"/>
                <textFieldExpression><![CDATA["param1: " + $P{Parameter1}]]></textFieldExpression>
                <reportElement x="120" y="50" width="277" height="30" uuid="f3d8943b-253f-4a90-8810-26802bb463d2"/>
                <textFieldExpression><![CDATA["param2: " + $P{Parameter2}]]></textFieldExpression>

robsil's picture
Joined: Jul 30 2010 - 5:28am
Last seen: 1 year 3 months ago

2 Answers:

I think this not make sense.

Parameters are for input users overall and to configure constant values wiht hidden parameters.

You can try to substitute param2 with a variable, perhaps this approach works better for you.


mlopez_1's picture
Joined: Oct 21 2013 - 8:08am
Last seen: 21 hours 14 min ago

Update... found the solution.  I had my "2nd" parameter setup as for prompting.  Once i removed that flag it processed the for prompting first... then it processed the not for prompting parameter and it resolved my issue.  I am still unclear on any sequence/order that exists when evaluating parameters (and variables) but at least a "for prompting" param gets evaluated before any that are not for prompting.

robsil's picture
Joined: Jul 30 2010 - 5:28am
Last seen: 1 year 3 months ago