
<< https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=672 >>


SECTION: Modified Files
----------------------------
M jsf-ri/src/com/sun/faces/mgbean/BeanBuilder.java
  - if the exepectedType is primitive, create the expression using
    the primitive type as the expected type so that coercion happens
    during expression evaluation.  Otherwise, create the expression 
    with the expected type as Object.  When evaluating, if this expression
    returns null, return null, otherwise coerce the non-null value
    to the expected type and return the result of the coercion.


SECTION: Diffs
----------------------------
Index: BeanBuilder.java
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/mgbean/BeanBuilder.java,v
retrieving revision 1.4
diff -u -r1.4 BeanBuilder.java
--- BeanBuilder.java	31 Jul 2007 22:09:03 -0000	1.4
+++ BeanBuilder.java	14 Dec 2007 19:18:38 -0000
@@ -541,10 +541,16 @@
                 validateLifespan(expScope, true);
             }
             if (ve == null) {
-                ve = ELUtils.createValueExpression(expressionString,
-                                                   expectedType);   
+                ve = ((expectedType.isPrimitive())
+                      ? ELUtils.createValueExpression(expressionString, expectedType)
+                      : ELUtils.createValueExpression(expressionString, Object.class));
+            }
+            if (expectedType.isPrimitive()) {
+                return ve.getValue(context);
+            } else {
+                Object tmpval = ve.getValue(context);
+                return ((tmpval != null) ? ELUtils.coerce(tmpval, expectedType) : null);
             }
-            return ve.getValue(context);
         }
 
 


