You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/07/20 23:10:30 UTC

svn commit: r966012 - /myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java

Author: jakobk
Date: Tue Jul 20 21:10:30 2010
New Revision: 966012

URL: http://svn.apache.org/viewvc?rev=966012&view=rev
Log:
MYFACES-2830 ourEL wrappers doesn't honour the new EL-2.2 'invoke' method (call getValueExpression() only once + minor refactoring)

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java?rev=966012&r1=966011&r2=966012&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/validator/BeanValidator.java Tue Jul 20 21:10:30 2010
@@ -131,14 +131,16 @@ public class BeanValidator implements Va
         if (context == null) throw new NullPointerException("context");
         if (component == null) throw new NullPointerException("component");
 
-        if (component.getValueExpression("value") == null)
+        ValueExpression valueExpression = component.getValueExpression("value");
+        if (valueExpression == null)
         {
-            log.warning("cannot validate component with empty value" + component.getId());
+            log.warning("cannot validate component with empty value: " 
+                    + component.getClientId(context));
             return;
         }
 
         // Obtain a reference to the to-be-validated object and the property name.
-        final _ValueReferenceWrapper reference = getValueReference(component, context);
+        final _ValueReferenceWrapper reference = getValueReference(valueExpression, context);
         if (reference == null)
         {
             return;
@@ -150,6 +152,11 @@ public class BeanValidator implements Va
         }
         
         final Class<?> valueBaseClass = base.getClass();
+        if (valueBaseClass == null)
+        {
+            return;
+        }
+        
         Object referenceProperty = reference.getProperty();
         if (!(referenceProperty instanceof String))
         {
@@ -159,10 +166,6 @@ public class BeanValidator implements Va
             return;
         }
         final String valueProperty = (String) referenceProperty;
-        if (valueBaseClass == null || valueProperty == null)
-        {
-            return;
-        }
 
         // Initialize Bean Validation.
         final ValidatorFactory validatorFactory = createValidatorFactory(context);
@@ -212,14 +215,14 @@ public class BeanValidator implements Va
     /**
      * Get the ValueReference from the ValueExpression.
      *
-     * @param component The component.
+     * @param valueExpression The ValueExpression for value.
      * @param context The FacesContext.
      * @return A ValueReferenceWrapper with the necessary information about the ValueReference.
      */
 
-    private _ValueReferenceWrapper getValueReference(final UIComponent component, final FacesContext context)
+    private _ValueReferenceWrapper getValueReference(
+            final ValueExpression valueExpression, final FacesContext context)
     {
-        final ValueExpression valueExpression = component.getValueExpression("value");
         final ELContext elCtx = context.getELContext();
         if (_ExternalSpecifications.isUnifiedELAvailable())
         {