jasperserver boolean parameter do not works properly

0

I have an string parameter with the following expression:

$P{One_Week}.toString().equals ("true") ? new String("2016-07-01"):new String("2016-07-02")

The parameter One_Week is defined as java.lang.Boolean

This expression is working properly in Jasper Studio 6.2.0, however when I try to use the same report in JasperServer, I'm getting the following error:

Error evaluating expression for source text: $P{One_Week}.toString().equals ("true") ? new String("2016-07-01"):new String("2016-07-02")

java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean 

 

Any idea why this works properly in studio but is not working on server?

 

Thanks in advance.

iscoscar's picture
Joined: Nov 17 2015 - 10:17am
Last seen: 4 months 4 weeks ago

Also tried the following expresion:

$P{One_Week}?  new String("2016-07-01"):new String("2016-07-02")

is the same problem, It's working on Studio but do not works on Server  (same erros message)

iscoscar - 2 years 11 months ago

one more expression with the same result, it works on Studio but not in Server:

new Boolean($P{One_Week}.toString()).equals("true")?  new String("2016-07-01"):new String("2016-07-02")

iscoscar - 2 years 11 months ago

 

Thanks @Hozawa

very simple solution, adding the Parenthesis on the condition works.  Jasper Studio dont require that format.

here the solution:

($P{One_Week}.toString().equals ("true")) ? new String("2016-07-01"):new String("2016-07-02")

 

Thanks,

 

iscoscar - 2 years 11 months ago

5 Answers:

1

Did you try putting the evaluation expression in paranthesis

($P{One_Week}.toString().equals ("true")) ? new String("2016-07-01"):new String("2016-07-02")

hozawa's picture
45039
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 month 1 week ago
0

Hi,

you can use( Your boolen field == Boolean.TRUE ? "Expression 1":"Expression 2")

hope this will help

 

AnilSaini's picture
Joined: Feb 28 2016 - 7:34pm
Last seen: 1 year 6 months ago
0

Thansk for your reply @AnilSaini 

I'm testing using your example... same result, works on Studio but not in Server.  Error message:

Error evaluating expression for source text: $P{One_Week} == Boolean.TRUE ? new String("2016-07-01"):new String("2016-07-02")

iscoscar's picture
Joined: Nov 17 2015 - 10:17am
Last seen: 4 months 4 weeks ago
0

Seems like $P{One _Week} is a type String and not a Boolean in JasperReports Server. 

Try,

($P{One_Week}.toLowerCase().equals ("true")) ? new String("2016-07-01"):new String("2016-07-02")

hozawa's picture
45039
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 month 1 week ago
0

Thanks @hozawa

The paramter One_Week is Boolean, below the section where I'm declaring the type

<parameter name="One_Week" class="java.lang.Boolean">
<defaultValueExpression><![CDATA["False"]]></defaultValueExpression>
</parameter>
 
I have tried the expression you suggested but I'm getting an error:
    The method toLowerCase() is undefined for type Boolean.
 
iscoscar's picture
Joined: Nov 17 2015 - 10:17am
Last seen: 4 months 4 weeks ago
Feedback