Hi. I have a little problem with expression in variable.
Code: |
<field name="Realizacja1" class="java.lang.Double"/><br /> <field name="Realizacja2" class="java.lang.Double"/><br /> <field name="Realizacja3" class="java.lang.Double"/><br /> <br /> <variable name="SumaRealizacjiAll" class="java.lang.Double" resetType="Report" calculation="Sum"><br /> <variableExpression><![CDATA[Double.valueOf($F{Realizacja1}.doubleValue()+$F{Realizacja2}.doubleValue()+$F{Realizacja3}.doubleValue())]]></variableExpression><br /> <initialValueExpression><![CDATA[new Double(0.0)]]></initialValueExpression><br /> </variable></td></tr></tbody></table><br /> <br /> from that expression when I try to fill report I get<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre>Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :<br /> Source text : Double.valueOf($F{Realizacja1}.doubleValue()+$F{Realizacja2}.doubleValue()+$F{Realizacja3}.doubleValue())<br /> at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:257)<br /> at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:528)<br /> at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:173)<br /> at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:780)<br /> at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1417)<br /> at net.sf.jasperreports.engine.fill.JRHorizontalFiller.fillReport(JRHorizontalFiller.java:115)<br /> at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891)<br /> at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:814)<br /> at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:523)<br /> at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:63)<br /> at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:209)<br /> ... 1 more<br /> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double</td></tr></tbody></table><br /> <br /> I tried this using new Double() instead of Double.valueOf() but it didn't work either.<br /> Anyone knows the sollution of this problem? |
2 Answers:
Posted on March 26, 2008 at 11:58am
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 - erer
Post edited by: erer, at: 2008/03/27 11:15
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 - erer
Post edited by: erer, at: 2008/03/27 11:15