Jump to content
Changes to the Jaspersoft community edition download ×

Scriptlet problem: variable inexistent!


roby1483

Recommended Posts

Hi to all,
 I have declared one variable in my subreport like this:

<variable name="ELEMENT_COUNT" class="java.lang.Integer" resetType="Report" calculation="Nothing">
<initialValueExpression><![CDATA[new Integer(0)]]></initialValueExpression>
</variable>

and I have created one scriptlet that increment this variable for each evaluated element: 

@Override
public void beforeDetailEval() throws JRScriptletException {
        Integer i = (Integer) getVariableValue("ELEMENT_COUNT");

if (i != null) {

int num = i.intValue();

num++;

setVariableValue("ELEMENT_COUNT"new Integer(num));

else

System.out.println("******* ELEMENT_COUNT not found ********");
}

I use this variable for print one line when the value is !=1 (for the first element the line will not be printed).

At the first execution all worked well but now (from yesterday afternoon) the scriptlet don't find the variable.

Can some one help me please?
Thanks at all.

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 Hi to all,

 anyone can help me? I have noticed that if I set the reset type as Report, the first execution of beforeDetailEval() find the variable but the subsequent execution not find it. If I set reset type as Nothing all execution of beforeDetailEval() not find the variable.

Link to comment
Share on other sites

 I have resolv without scriptlet and with this variable declaration:

<variable name="NUM_ELEM" class="java.lang.Integer" resetType="Report" calculation="Nothing">
          <variableExpression><![CDATA[new Integer($V{NUM_ELEM}.intValue() + 1)]]></variableExpression>
          <initialValueExpression><![CDATA[new Integer(0)]]></initialValueExpression>
</variable>

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