Error evaluating expression for Integer.valueOf($P{string})

0

hey folks,

i get an evaluation error for parsing a string to an int with "Integer.valueOf(<string-param>)".

<parameter name="s_incident" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression>
        ![CDATA[new String("")]]
    </defaultValueExpression>
</parameter>
<parameter name="q_incident" class="java.lang.Integer" isForPrompting="false">
    <defaultValueExpression>
        ![CDATA[IF($P{s_incident}.trim().length() > 0,Integer.valueOf($P{s_incident}),new java.lang.Integer(0))]]
    </defaultValueExpression>
</parameter>

the string parameter is used as input control in the JasperReporting Server (i want the field to be blank at the beginning).

the int parameter is used in the sql query.

Hope someone can help me..

best regards, Philipp

philipp.fresen's picture
Joined: May 8 2019 - 7:25am
Last seen: 1 year 10 months ago

The problem is based on the empty default value of the string parameter.

does anyone know how the default value for an integer is in Jasper?

philipp.fresen - 1 year 11 months ago

don't find another way to answer this...

@C-Box

Thanks!

Worked direktly

philipp.fresen - 1 year 11 months ago

No problem! Nice, when it works now & I could help!

regards from Dresden/Germany

C-Box

C-Box - 1 year 11 months ago

1 Answer:

1

I would use following as Default Expression for your Integer Parameter:

$P{s_incident} == null || "".equals($P{s_incident}.trim())? new Integer(0) : Integer.valueOf($P{s_incident})

hth + regards

C-Box

C-Box's picture
2394
Joined: Jul 19 2006 - 5:58pm
Last seen: 1 week 6 days ago
Feedback
randomness