erer Posted March 26, 2008 Share Posted March 26, 2008 Hi. I have a little problem with expression in variable.Code: <field name="Realizacja1" class="java.lang.Double"/> <field name="Realizacja2" class="java.lang.Double"/> <field name="Realizacja3" class="java.lang.Double"/> <variable name="SumaRealizacjiAll" class="java.lang.Double" resetType="Report" calculation="Sum"> <variableExpression><![CDATA[Double.valueOf($F{Realizacja1}.doubleValue()+$F{Realizacja2}.doubleValue()+$F{Realizacja3}.doubleValue())]]></variableExpression> <initialValueExpression><![CDATA[new Double(0.0)]]></initialValueExpression> </variable> from that expression when I try to fill report I getCode:[code]Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : Double.valueOf($F{Realizacja1}.doubleValue()+$F{Realizacja2}.doubleValue()+$F{Realizacja3}.doubleValue()) at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:257) at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:528) at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:173) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:780) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1417) at net.sf.jasperreports.engine.fill.JRHorizontalFiller.fillReport(JRHorizontalFiller.java:115) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:814) at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:523) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:63) at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:209) ... 1 moreCaused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double I tried this using new Double() instead of Double.valueOf() but it didn't work either.Anyone knows the sollution of this problem? Link to comment Share on other sites More sharing options...
dnvsrikanth Posted March 26, 2008 Share Posted March 26, 2008 hi erer, I think one of the fields you are retrieving may be of String type in database. Check whether all the fields are of String type or of Double type in database Link to comment Share on other sites More sharing options...
erer Posted March 26, 2008 Author Share Posted March 26, 2008 That's not that either. First, I have ale of these fields printed in report as Double and they are printed correctly and there is no exception. Second, I have converter to Double, that for sure returns Double and then those values goes to fill process. So that's not the problem for sure. I don't really know what's going on, because i can't view source at the moment. I tried almost everyting that came to my head. Still it doesn't work. Please, help someone :P best regards - erer ed: PS. for clearance. In database those fields are numeric, retrieved from it as BigDecimal, and converted to Double. That for sure works fine. ed2: Problem solved. All beacuse m stupidity :P Expression above is ok. For the first time my datasource has column names all messed up. That was the problem. Values were put to datasource in strict order, but names of the collumns were in diffrent order and group name was instead of grup value and so on. best regards - ererPost edited by: erer, at: 2008/03/27 11:15 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