myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r711557 - in /myfaces/extensions/validator/trunk: core/src/main/java/org/apache/myfaces/extensions/validator/core/ core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ core/src/main/java/org/apache/myfaces/extensions/validato...
Date Wed, 05 Nov 2008 12:12:46 GMT
Author: gpetracek
Date: Wed Nov  5 04:12:46 2008
New Revision: 711557

URL: http://svn.apache.org/viewvc?rev=711557&view=rev
Log:
extval el-resolver as default approach

Modified:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java?rev=711557&r1=711556&r2=711557&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
Wed Nov  5 04:12:46 2008
@@ -83,12 +83,6 @@
         .getInitParameter("CUSTOM_COMPONENT_INITIALIZER_FACTORY");
 
     /*
-     * activate
-     */
-    static final String ACTIVATE_EL_RESOLVER = WebXmlUtils
-        .getInitParameter("ACTIVATE_EL_RESOLVER");
-
-    /*
      * deactivate
      */
     static final String DEACTIVATE_RENDERKIT = WebXmlUtils
@@ -97,6 +91,9 @@
     static final String DEACTIVATE_DEFAULT_CONVENTION = WebXmlUtils
         .getInitParameter("DEACTIVATE_DEFAULT_CONVENTION");
 
+    static final String DEACTIVATE_EL_RESOLVER = WebXmlUtils
+        .getInitParameter("DEACTIVATE_EL_RESOLVER");
+
     //there is nothing like DEACTIVATE_DEFAULT_VALIDATION_INTERCEPTOR
     //use ExtValContext.getContext().denyRendererInterceptor(...) within an extval-StartupListener
 }

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java?rev=711557&r1=711556&r2=711557&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
Wed Nov  5 04:12:46 2008
@@ -25,6 +25,7 @@
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
 import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.ExtValInformation;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -52,7 +53,7 @@
 @UsageInformation(UsageCategory.INTERNAL)
 public class DefaultELHelper implements ELHelper
 {
-    private static final String ACTIVATE_EL_RESOLVER = WebXmlParameter.ACTIVATE_EL_RESOLVER;
+    private static final String DEACTIVATE_EL_RESOLVER = WebXmlParameter.DEACTIVATE_EL_RESOLVER;
 
     protected final Log logger = LogFactory.getLog(getClass());
 
@@ -168,39 +169,48 @@
         return new ValueBindingExpression(valueBindingExpression);
     }
 
-    public PropertyDetails getTargetInformation(UIComponent uiComponent)
+    public PropertyDetails getPropertyDetailsOfValueBinding(UIComponent uiComponent)
     {
-        if("true".equalsIgnoreCase(ACTIVATE_EL_RESOLVER))
+        if("true".equalsIgnoreCase(DEACTIVATE_EL_RESOLVER))
         {
-            FacesContext facesContext = FacesContext.getCurrentInstance();
+            return getPropertyDetailsViaReflectionFallback(uiComponent);
+        }
 
-            ExtValELResolver elResolver = new ExtValELResolver(facesContext.getApplication().getELResolver());
-            ELContext elContext = ExtValELResolver.createContextWrapper(facesContext.getELContext(),
elResolver);
+        FacesContext facesContext = FacesContext.getCurrentInstance();
 
-            ValueExpression valueExpression = uiComponent.getValueExpression("value");
+        ExtValELResolver elResolver = new ExtValELResolver(facesContext.getApplication().getELResolver());
+        ELContext elContext = ExtValELResolver.createContextWrapper(facesContext.getELContext(),
elResolver);
 
-            if(valueExpression == null)
-            {
-                return null;
-            }
+        ValueExpression valueExpression = uiComponent.getValueExpression("value");
 
-            try
-            {
-                valueExpression.setValue(elContext, null);
-            }
-            catch (Throwable t)
-            {
-                throw new IllegalStateException("please don't activate the el-resovler of
extval. " +
-                    "there's a bug in the el impl. you are using.");
-            }
+        if(valueExpression == null)
+        {
+            return null;
+        }
 
-            if(elResolver.getPath() != null && elResolver.getBaseObject() != null
&& elResolver.getProperty() != null)
-            {
-                return new PropertyDetails(
-                    elResolver.getPath(), elResolver.getBaseObject(), elResolver.getProperty());
-            }
+        try
+        {
+            valueExpression.setValue(elContext, null);
+        }
+        catch (Throwable t)
+        {
+            throw new IllegalStateException(
+                "an el-resolver error occurred! " +
+                "please report the issue, deactivate the el-resovler of extval via web.xml
context-param: " +
+                ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_EL_RESOLVER" +
+                " and test again.");
         }
 
+        if(elResolver.getPath() == null || elResolver.getBaseObject() == null || elResolver.getProperty()
== null)
+        {
+            return null;
+        }
+
+        return new PropertyDetails(elResolver.getPath(), elResolver.getBaseObject(), elResolver.getProperty());
+    }
+
+    private PropertyDetails getPropertyDetailsViaReflectionFallback(UIComponent uiComponent)
+    {
         ValueBindingExpression valueBindingExpression = getValueBindingExpression(uiComponent,
false);
 
         if(valueBindingExpression == null)

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java?rev=711557&r1=711556&r2=711557&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java
Wed Nov  5 04:12:46 2008
@@ -46,7 +46,7 @@
 
     Object getValueOfExpression(FacesContext facesContext, ValueBindingExpression valueBindingExpression);
 
-    PropertyDetails getTargetInformation(UIComponent uiComponent);
+    PropertyDetails getPropertyDetailsOfValueBinding(UIComponent uiComponent);
 
     boolean isExpressionValid(FacesContext facesContext, String valueBindingExpression);
 

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java?rev=711557&r1=711556&r2=711557&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java
Wed Nov  5 04:12:46 2008
@@ -88,6 +88,7 @@
         expression += "." + o1;
         property = (String)o1;
         baseObject = o;
+        elContext.setPropertyResolved(true);
     }
 
     public boolean isReadOnly(ELContext elContext, Object o, Object o1)

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java?rev=711557&r1=711556&r2=711557&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
Wed Nov  5 04:12:46 2008
@@ -79,7 +79,7 @@
         }
 
         PropertyDetails propertyDetails =
-            ExtValUtils.getELHelper().getTargetInformation(uiComponent);
+            ExtValUtils.getELHelper().getPropertyDetailsOfValueBinding(uiComponent);
 
         if (propertyDetails == null)
         {

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java?rev=711557&r1=711556&r2=711557&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
Wed Nov  5 04:12:46 2008
@@ -54,7 +54,7 @@
         ProcessedInformationEntry entry;
 
         PropertyDetails propertyDetails =
-            ExtValUtils.getELHelper().getTargetInformation(uiComponent);
+            ExtValUtils.getELHelper().getPropertyDetailsOfValueBinding(uiComponent);
 
         if(propertyDetails == null)
         {



Mime
View raw message