Ajenjo Posted March 26, 2008 Share Posted March 26, 2008 Hi. I have a class with these atributtes. Code:/** * Constructor for required fields */ public BaseAlbaranCuadernosLineas ( java.lang.Integer id, com.siega.vo.Albarancuadernos idAlbarancuadernos, java.lang.String concepto, java.lang.Integer cantidad, java.lang.Float precio, java.lang.Float iva, java.lang.Float importe) {(...) As you see, I have type Integer, Float and String. In the .jrxml are the following fields. Code:[code](...) <field name="concepto" class="java.lang.String"/> <field name="cantidad" class="java.lang.Integer"/> <field name="precio" class="java.lang.Float"/> <field name="iva" class="java.lang.Float"/> <field name="importe" class="java.lang.Float"/>(...) But when I compile the file, show the next error: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Cannot cast from Float to String value = (java.lang.String)(((java.lang.Float)field_iva.getValue()));//$JR_EXPR_ID=12$ <---------------------------------------------------------> 2. Cannot cast from Float to String (...) And when I change the types to String the error show that it´s not good value for the type. Error evaluating expression : Source text : $F{cantidad} I can´t change the types because I have to do some operations with the values. Any idea? ThanksPost edited by: Ajenjo, at: 2008/03/25 18:06 Link to comment Share on other sites More sharing options...
lucianc Posted March 26, 2008 Share Posted March 26, 2008 Ajenjo wrote:net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Cannot cast from Float to String value = (java.lang.String)(((java.lang.Float)field_iva.getValue()));//$JR_EXPR_ID=12$ <---------------------------------------------------------> 2. Cannot cast from Float to String I assume you have a text field that uses an expression likeCode:<textFieldExpression>$F{iva}</textFieldExpression> If this is the case, you will have to change it toCode:[code]<textFieldExpression class="java.lang.Float">$F{iva}</textFieldExpression> If this is not the case, please post your entire JRXML so that we can see where the error comes from. Regards,Lucian 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