Yippie Posted November 9, 2006 Share Posted November 9, 2006 Hello, I'm encountering the following error when I run a report. My deployment server key info is: Suse Linux Enterprise EditionApache Tomcat 5.5.17Java 1.5Jasper Report version 1.2.5I created the report using iReport 1.2.5. The error is: javax.faces.el.EvaluationException: java.lang.Exception: Error evaluating expression : Source text : new BigDecimal($F{lastYearSales}) Here is the situation. The report gets it's data from a custom Java Bean that returns a array of String objects. The report is a purchase history report that breaks on the Customer's name. Initially, no sub-totals were needed, but now the user's want to see a sub-total. Rather than rewrite the bean to return a multi data type array, we just removed the currency format from the dollar Strings and I am trying to case the String object to a BigDecimal object using the following in my Variable Expression: new BigDecimal($F{dollars}). I have even tried: new java.math.BigDecimal($F{dollars}). Both work just fine when I run the report from iReport. When I run the report from my JSF application, I get the aforementioned error. Does anyone have any suggestions? Thanks in advance. Craig... Link to comment Share on other sites More sharing options...
C-Box Posted November 10, 2006 Share Posted November 10, 2006 we made a helper class for that, because the expression were too long otherwise: just make a class that is within the classpath at runtime: as FieldExpression I use: Code:MathLib.stringToBigDecimal($F{StringFieldThatContainsBD}) Code:[code]....public static BigDecimal stringToBigDecimal(String str) { return MathLib.stringToBigDecimal(str, "###,###,##0.00", 2); } public static BigDecimal stringToBigDecimal(String str, String format, int nachkommastellen) { if (str.length() > 0) { DecimalFormat df = new DecimalFormat(format); Number x; try { x = df.parse(str); BigDecimal y = new BigDecimal(Double.toString(x.doubleValue())); y = round(y, nachkommastellen); return y; } catch (ParseException e) { return new BigDecimal(0); } } else { return new BigDecimal(0); } }} public static BigDecimal round(BigDecimal zahl, int nachkommastellen) { if (zahl == null) { zahl = BigDecimal.ZERO; } return zahl.setScale(nachkommastellen, BigDecimal.ROUND_HALF_UP); }.... hthC-BoxPost edited by: CBox, at: 2006/11/09 16:16 Link to comment Share on other sites More sharing options...
Yippie Posted November 15, 2006 Author Share Posted November 15, 2006 CBox, Thanks for the suggestion. I'll give that a try. Craig... 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