You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/11/11 18:04:41 UTC
svn commit: r1034001 -
/myfaces/core/trunk/api/src/main/java/javax/faces/convert/NumberConverter.java
Author: lu4242
Date: Thu Nov 11 17:04:41 2010
New Revision: 1034001
URL: http://svn.apache.org/viewvc?rev=1034001&view=rev
Log:
MYFACES-1890 Numberconverter has issue with bigdecimal
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/convert/NumberConverter.java
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/NumberConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/NumberConverter.java?rev=1034001&r1=1034000&r2=1034001&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/NumberConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/NumberConverter.java Thu Nov 11 17:04:41 2010
@@ -109,7 +109,22 @@ public class NumberConverter
format.setParseIntegerOnly(_integerOnly);
DecimalFormat df = (DecimalFormat)format;
- //df.setParseBigDecimal(true);
+
+ // The best we can do in this case is check if there is a ValueExpression
+ // with a BigDecimal as returning type , and if that so enable BigDecimal parsing
+ // to prevent loss in precision, and do not break existing examples (since
+ // in those cases it is expected to return Double). See MYFACES-1890 and TRINIDAD-1124
+ // for details
+ ValueExpression valueBinding = uiComponent.getValueExpression("value");
+ if (valueBinding != null)
+ {
+ Class<?> destType = valueBinding.getType(facesContext.getELContext());
+ if (destType != null && BigDecimal.class.isAssignableFrom(destType))
+ {
+ df.setParseBigDecimal(true);
+ }
+ }
+
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
boolean changed = false;
if(dfs.getGroupingSeparator() == '\u00a0')