askme Posted January 9, 2010 Share Posted January 9, 2010 Hi all, I am using a conditional statement to change the font color in jrxml. The condition is if the value is greater than 0 then one color else another color.Please find the statement that i used in the jrxml file in the code section below.The field is of type string <field name="total" class="java.lang.String"/> I get the following error when i try to generate the report net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. The method doubleValue() is undefined for the type String value = (java.lang.String)(((java.lang.String)field_total.getValue()).doubleValue() >0.0 ? //$JR_EXPR_ID=16$ <--------->2. The method doubleValue() is undefined for the type String value = (java.lang.String)(((java.lang.String)field_total.getOldValue()).doubleValue() >0.0 ? //$JR_EXPR_ID=16$ <--------->3. The method doubleValue() is undefined for the type String value = (java.lang.String)(((java.lang.String)field_total.getValue()).doubleValue() >0.0 ? //$JR_EXPR_ID=16$ <---------> ThanksCode:<textField > <reportElement x="607" y="0" width="70" height="20"/> <textElement textAlignment="Center"/> <textFieldExpression class="java.lang.String"><![CDATA[$F{total}.doubleValue() >0.0 ? ("<style forecolor='#ff0000'>"+ $F{total}.toString()+"</style>"): ("<style forecolor='#0000ff'>"+ $F{total}.toString()+"</style>")]]></textFieldExpression> </textField> Link to comment Share on other sites More sharing options...
teamireport Posted January 11, 2010 Share Posted January 11, 2010 looks like datatype that you defined for the field (total) as string and you condtional statement is expecting your field to be an integer.so, could you try changing the datatype of 'total' from string to integer /double.? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now