myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r711295 - 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 Tue, 04 Nov 2008 16:20:56 GMT
Author: gpetracek
Date: Tue Nov  4 08:20:55 2008
New Revision: 711295

URL: http://svn.apache.org/viewvc?rev=711295&view=rev
Log:
new data structure to allow alternative el-resolver approach

Added:
    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/el/TargetInformationEntry.java
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/metadata/PropertySourceInformationKeys.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/strategy/JoinValidationStrategy.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/ELCompareStrategy.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalCompareStrategy.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalPropertyChainCompareStrategy.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/util/CrossValidationUtils.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=711295&r1=711294&r2=711295&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 Tue Nov  4 08:20:55 2008
@@ -83,6 +83,12 @@
         .getInitParameter("CUSTOM_COMPONENT_INITIALIZER_FACTORY");
 
     /*
+     * activate
+     */
+    static final String ACTIVATE_EL_RESOLVER = WebXmlUtils
+        .getInitParameter("ACTIVATE_EL_RESOLVER");
+
+    /*
      * deactivate
      */
     static final String DEACTIVATE_RENDERKIT = WebXmlUtils

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=711295&r1=711294&r2=711295&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 Tue Nov  4 08:20:55 2008
@@ -23,10 +23,12 @@
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.el.ValueExpression;
+import javax.el.ELContext;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
@@ -49,6 +51,8 @@
 @UsageInformation(UsageCategory.INTERNAL)
 public class DefaultELHelper implements ELHelper
 {
+    private static final String ACTIVATE_EL_RESOLVER = WebXmlParameter.ACTIVATE_EL_RESOLVER;
+
     protected final Log logger = LogFactory.getLog(getClass());
 
     public DefaultELHelper()
@@ -109,12 +113,12 @@
         return true;
     }
 
-    public ValueBindingExpression getValueBindingExpression(UIComponent uiComponent)
+    private ValueBindingExpression getValueBindingExpression(UIComponent uiComponent)
     {
         return getValueBindingExpression(uiComponent, false);
     }
 
-    public ValueBindingExpression getValueBindingExpression(UIComponent uiComponent, boolean allowBlankCharacters)
+    private ValueBindingExpression getValueBindingExpression(UIComponent uiComponent, boolean allowBlankCharacters)
     {
         String valueBindingExpression = getOriginalValueBindingExpression(uiComponent);
 
@@ -163,6 +167,70 @@
         return new ValueBindingExpression(valueBindingExpression);
     }
 
+    public TargetInformationEntry getTargetInformation(UIComponent uiComponent)
+    {
+        if("true".equalsIgnoreCase(ACTIVATE_EL_RESOLVER))
+        {
+            FacesContext facesContext = FacesContext.getCurrentInstance();
+
+            ExtValELResolver elResolver = new ExtValELResolver(facesContext.getApplication().getELResolver());
+            ELContext elContext = ExtValELResolver.createContextWrapper(facesContext.getELContext(), elResolver);
+
+            ValueExpression valueExpression = uiComponent.getValueExpression("value");
+
+            if(valueExpression == null)
+            {
+                return null;
+            }
+
+            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(elResolver.getPath() != null && elResolver.getBaseObject() != null && elResolver.getProperty() != null)
+            {
+                return new TargetInformationEntry(
+                    elResolver.getPath(), elResolver.getBaseObject(), elResolver.getProperty());
+            }
+        }
+
+        ValueBindingExpression valueBindingExpression = getValueBindingExpression(uiComponent, false);
+
+        if(valueBindingExpression == null)
+        {
+            return null;
+        }
+
+        ValueBindingExpression currentValueBindingExpression =
+            new ValueBindingExpression(valueBindingExpression.getExpressionString());
+        String path = null;
+
+        while(currentValueBindingExpression.getBaseExpression() != null)
+        {
+            if(path == null)
+            {
+                path = currentValueBindingExpression.getProperty();
+            }
+            else
+            {
+                path = currentValueBindingExpression.getProperty() + "." + path;
+            }
+
+            currentValueBindingExpression = currentValueBindingExpression.getBaseExpression();
+        }
+
+        path = currentValueBindingExpression.getProperty() + "." + path;
+
+        return new TargetInformationEntry(path,
+            getBaseObject(valueBindingExpression), valueBindingExpression.getProperty());
+    }
+
     static String getOriginalValueBindingExpression(UIComponent uiComponent)
     {
         ValueExpression valueExpression = uiComponent.getValueExpression("value");

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=711295&r1=711294&r2=711295&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 Tue Nov  4 08:20:55 2008
@@ -45,9 +45,7 @@
 
     Object getValueOfExpression(FacesContext facesContext, ValueBindingExpression valueBindingExpression);
 
-    ValueBindingExpression getValueBindingExpression(UIComponent uiComponent);
-
-    ValueBindingExpression getValueBindingExpression(UIComponent uiComponent, boolean allowBlankCharacters);
+    TargetInformationEntry getTargetInformation(UIComponent uiComponent);
 
     boolean isExpressionValid(FacesContext facesContext, String valueBindingExpression);
 

Added: 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=711295&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ExtValELResolver.java Tue Nov  4 08:20:55 2008
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.el;
+
+import javax.el.ELResolver;
+import javax.el.ELContext;
+import javax.el.VariableMapper;
+import javax.el.FunctionMapper;
+import java.util.Iterator;
+import java.util.Locale;
+import java.beans.FeatureDescriptor;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+public class ExtValELResolver extends ELResolver
+{
+    private ELResolver wrapped;
+    private Object baseObject;
+    private String property;
+    //forms the id for cross-validation within complex components
+    private String expression;
+
+    public ExtValELResolver(ELResolver elResolver)
+    {
+        this.wrapped = elResolver;
+    }
+
+    public Object getBaseObject()
+    {
+        return baseObject;
+    }
+
+    public String getProperty()
+    {
+        return property;
+    }
+
+    public String getPath()
+    {
+        return expression;
+    }
+
+    public void reset()
+    {
+        this.baseObject = null;
+        this.property = null;
+        this.expression = null;
+    }
+
+    public Object getValue(ELContext elContext, Object base, Object property)
+    {
+        if(this.expression == null)
+        {
+            this.expression = (String)property;
+        }
+        else
+        {
+            this.expression += "." + property;
+        }
+        return wrapped.getValue(elContext, base, property);
+    }
+
+    public Class<?> getType(ELContext elContext, Object o, Object o1)
+    {
+        return wrapped.getType(elContext, o, o1);
+    }
+
+    public void setValue(ELContext elContext, Object o, Object o1, Object o2)
+    {
+        expression += "." + o1;
+        property = (String)o1;
+        baseObject = o;
+    }
+
+    public boolean isReadOnly(ELContext elContext, Object o, Object o1)
+    {
+        return wrapped.isReadOnly(elContext, o, o1);
+    }
+
+    public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext elContext, Object o)
+    {
+        return wrapped.getFeatureDescriptors(elContext, o);
+    }
+
+    public Class<?> getCommonPropertyType(ELContext elContext, Object o)
+    {
+        return wrapped.getCommonPropertyType(elContext, o);
+    }
+
+    public static ELContext createContextWrapper(final ELContext context, final ELResolver resolver)
+    {
+        return new ELContext()
+        {
+            @Override
+            public Locale getLocale()
+            {
+                return context.getLocale();
+            }
+
+            @Override
+            public void setPropertyResolved(boolean value)
+            {
+                super.setPropertyResolved(value);
+                context.setPropertyResolved(value);
+            }
+
+            @Override
+            public void putContext(Class clazz, Object object)
+            {
+                super.putContext(clazz, object);
+                context.putContext(clazz, object);
+            }
+
+            @Override
+            public Object getContext(Class clazz)
+            {
+                return context.getContext(clazz);
+            }
+
+            @Override
+            public void setLocale(Locale locale)
+            {
+                super.setLocale(locale);
+                context.setLocale(locale);
+            }
+
+            @Override
+            public ELResolver getELResolver()
+            {
+                return resolver;
+            }
+
+            @Override
+            public FunctionMapper getFunctionMapper()
+            {
+                return context.getFunctionMapper();
+            }
+
+            @Override
+            public VariableMapper getVariableMapper()
+            {
+                return context.getVariableMapper();
+            }
+
+        };
+    }
+}

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/TargetInformationEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/TargetInformationEntry.java?rev=711295&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/TargetInformationEntry.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/TargetInformationEntry.java Tue Nov  4 08:20:55 2008
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.el;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+public class TargetInformationEntry
+{
+    //forms the id for cross-validation within complex components
+    private String key;
+    private Object baseObject;
+    private String property;
+
+    public TargetInformationEntry(String key, Object baseObject, String property)
+    {
+        this.key = key;
+        this.baseObject = baseObject;
+        this.property = property;
+    }
+
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey(String key)
+    {
+        this.key = key;
+    }
+
+    public Object getBaseObject()
+    {
+        return baseObject;
+    }
+
+    public void setBaseObject(Object baseObject)
+    {
+        this.baseObject = baseObject;
+    }
+
+    public String getProperty()
+    {
+        return property;
+    }
+
+    public void setProperty(String property)
+    {
+        this.property = property;
+    }
+}

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/PropertySourceInformationKeys.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/PropertySourceInformationKeys.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/PropertySourceInformationKeys.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/PropertySourceInformationKeys.java Tue Nov  4 08:20:55 2008
@@ -28,6 +28,6 @@
 @UsageInformation(UsageCategory.INTERNAL)
 public interface PropertySourceInformationKeys
 {
-    static final String VALUE_BINDING_EXPRESSION = "value_binding_expression";
+    static final String TARGET_INFORMATION_ENTRY = "target_information_entry";
     static final String SKIP_VALIDATION = "skip_validation";
 }

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=711295&r1=711294&r2=711295&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 Tue Nov  4 08:20:55 2008
@@ -18,7 +18,7 @@
  */
 package org.apache.myfaces.extensions.validator.core.metadata.extractor;
 
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
 import org.apache.myfaces.extensions.validator.core.metadata.SourceInformation;
 import org.apache.myfaces.extensions.validator.core.metadata.DefaultSourceInformation;
 import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
@@ -78,10 +78,10 @@
             logger.trace("start extracting meta-data of " + uiComponent.getClass().getName());
         }
 
-        ValueBindingExpression vbe =
-            ExtValUtils.getELHelper().getValueBindingExpression(uiComponent);
+        TargetInformationEntry targetInformationEntry =
+            ExtValUtils.getELHelper().getTargetInformation(uiComponent);
 
-        if (vbe == null)
+        if (targetInformationEntry == null)
         {
             return sourceInformation;
         }
@@ -89,13 +89,10 @@
         /*
          * get bean class and property name
          */
-        Class entityClass = ExtValUtils.getELHelper()
-            .getTypeOfValueBindingForExpression(facesContext, vbe.getBaseExpression());
+        Class entityClass = targetInformationEntry.getBaseObject().getClass();
 
-        //create template entry
-        //TODO test with complex components
-        sourceInformation.setProperty(
-            PropertySourceInformationKeys.VALUE_BINDING_EXPRESSION, vbe.getExpressionString());
+        //create
+        sourceInformation.setProperty(PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY, targetInformationEntry);
 
         /*
          * find and add annotations
@@ -104,9 +101,8 @@
 
         while (!Object.class.getName().equals(currentClass.getName()))
         {
-            //TODO map syntax support
-            addPropertyAccessAnnotations(currentClass, vbe.getProperty(), sourceInformation);
-            addFieldAccessAnnotations(currentClass, vbe.getProperty(), sourceInformation);
+            addPropertyAccessAnnotations(currentClass, targetInformationEntry.getProperty(), sourceInformation);
+            addFieldAccessAnnotations(currentClass, targetInformationEntry.getProperty(), sourceInformation);
 
             currentClass = currentClass.getSuperclass();
         }
@@ -117,7 +113,7 @@
 
             while (currentClass != null)
             {
-                addPropertyAccessAnnotations(currentClass, vbe.getProperty(), sourceInformation);
+                addPropertyAccessAnnotations(currentClass, targetInformationEntry.getProperty(), sourceInformation);
 
                 currentClass = currentClass.getSuperclass();
             }

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java Tue Nov  4 08:20:55 2008
@@ -26,10 +26,14 @@
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
 import org.apache.myfaces.extensions.validator.core.el.ELHelper;
 import org.apache.myfaces.extensions.validator.core.el.AbstractELHelperFactory;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
+import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
 import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
 import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractorFactory;
 import org.apache.myfaces.extensions.validator.core.initializer.component.ComponentInitializer;
 import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
 
 import javax.faces.component.UIComponent;
@@ -90,4 +94,30 @@
         return ExtValContext.getContext().getFactoryFinder()
             .getFactory(FactoryNames.EL_HELPER_FACTORY, AbstractELHelperFactory.class).create();
     }
+
+    public static TargetInformationEntry createTargetInformationEntryForNewTarget(MetaDataEntry metaDataEntry,
+                                                                                  String targetExpression)
+    {
+        Object baseObject;
+        if(ExtValUtils.getELHelper().isELTerm(targetExpression))
+        {
+            ValueBindingExpression vbe = new ValueBindingExpression(targetExpression);
+
+            String expression = vbe.getExpressionString();
+            baseObject = ExtValUtils.getELHelper().getBaseObject(vbe);
+            return new TargetInformationEntry(
+                expression.substring(2, expression.length() - 1), baseObject, vbe.getProperty());
+        }
+
+        TargetInformationEntry original = metaDataEntry.getProperty(
+            PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY, TargetInformationEntry.class);
+
+        String newBaseKey = original.getKey().substring(0, original.getKey().lastIndexOf(".") + 1);
+        String newKey = newBaseKey + targetExpression;
+
+        baseObject = ReflectionUtils.getBaseOfPropertyChain(original.getBaseObject(), targetExpression);
+        return new TargetInformationEntry(
+            newKey, baseObject, targetExpression.substring(targetExpression.lastIndexOf(".") + 1,
+            targetExpression.length()));
+    }
 }

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java Tue Nov  4 08:20:55 2008
@@ -23,6 +23,7 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.StringTokenizer;
 
 /**
  * @author Gerhard Petracek
@@ -150,4 +151,32 @@
     {
         return method.invoke(target, args);
     }
+
+    public static Object getBaseOfPropertyChain(Object baseObject, String propertyChain)
+    {
+        StringTokenizer tokenizer = new StringTokenizer(propertyChain, ".");
+
+        Object currentBase = baseObject;
+        String currentProperty;
+        Method currentMethod;
+
+        while(tokenizer.hasMoreTokens())
+        {
+            currentProperty = tokenizer.nextToken();
+
+            //ignore the last property
+            if(!tokenizer.hasMoreTokens())
+            {
+                break;
+            }
+
+            //no is - it's only possible at properties not at bean level
+            currentMethod = tryToGetMethod(currentBase.getClass(),
+                "get" + currentProperty.substring(0, 1).toUpperCase() +
+                    currentProperty.substring(1, currentProperty.length()));
+            currentBase = tryToInvokeMethod(currentBase, currentMethod);
+        }
+
+        return currentBase;
+    }
 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java Tue Nov  4 08:20:55 2008
@@ -22,12 +22,11 @@
 import org.apache.myfaces.extensions.validator.core.metadata.DefaultSourceInformation;
 import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
 import org.apache.myfaces.extensions.validator.internal.ToDo;
 import org.apache.myfaces.extensions.validator.internal.Priority;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
-import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 
 import javax.faces.context.FacesContext;
 
@@ -43,30 +42,25 @@
     public SourceInformation extract(FacesContext facesContext, Object object)
     {
         SourceInformation sourceInformation = new DefaultSourceInformation();
-        //should never occur
-        if (!(object instanceof String))
+
+        if (!(object instanceof TargetInformationEntry))
         {
-            return sourceInformation;
+            throw new IllegalStateException(object.getClass() + " is not a " + TargetInformationEntry.class.getName());
         }
 
-        ValueBindingExpression valueBindingExpression = new ValueBindingExpression(((String) object).trim());
+        TargetInformationEntry targetInformationEntry = (TargetInformationEntry)object;
 
-        Class entityClass = ExtValUtils.getELHelper()
-            .getTypeOfValueBindingForExpression(facesContext, valueBindingExpression.getBaseExpression());
+        Class entityClass = targetInformationEntry.getBaseObject().getClass();
 
-        //TODO complex components
+        //TODO test with complex components
         sourceInformation.setProperty(
-            PropertySourceInformationKeys.VALUE_BINDING_EXPRESSION, valueBindingExpression.getExpressionString());
+            PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY, targetInformationEntry);
 
         /*
          * find and add annotations
          */
-        if (entityClass != null)
-        {
-            //TODO map syntax support
-            addPropertyAccessAnnotations(entityClass, valueBindingExpression.getProperty(), sourceInformation);
-            addFieldAccessAnnotations(entityClass, valueBindingExpression.getProperty(), sourceInformation);
-        }
+        addPropertyAccessAnnotations(entityClass, targetInformationEntry.getProperty(), sourceInformation);
+        addFieldAccessAnnotations(entityClass, targetInformationEntry.getProperty(), sourceInformation);
 
         return sourceInformation;
     }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java Tue Nov  4 08:20:55 2008
@@ -21,11 +21,10 @@
 import org.apache.myfaces.extensions.validator.baseval.annotation.JoinValidation;
 import org.apache.myfaces.extensions.validator.baseval.annotation.extractor.DefaultPropertyScanningMetaDataExtractor;
 import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
-import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
 import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
 import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
@@ -52,12 +51,14 @@
 
         Map<String, Object> results = new HashMap<String, Object>();
 
+        TargetInformationEntry targetInformationEntry;
         for (String targetExpression : targetExpressions)
         {
-            targetExpression = createValidBinding(metaDataEntry, targetExpression);
+            targetInformationEntry = ExtValUtils
+                .createTargetInformationEntryForNewTarget(metaDataEntry, targetExpression);
 
             for (MetaDataEntry entry : extractor.extract(FacesContext.getCurrentInstance(),
-                                                                    targetExpression).getMetaDataEntries())
+                                                                    targetInformationEntry).getMetaDataEntries())
             {
                 validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
 
@@ -71,16 +72,4 @@
         }
         return results;
     }
-
-    private String createValidBinding(MetaDataEntry metaDataEntry, String targetExpression)
-    {
-        if(ExtValUtils.getELHelper().isELTerm(targetExpression))
-        {
-            return targetExpression;
-        }
-        
-        ValueBindingExpression baseExpression = new ValueBindingExpression(
-            metaDataEntry.getProperty(PropertySourceInformationKeys.VALUE_BINDING_EXPRESSION, String.class));
-        return ValueBindingExpression.replaceOrAddProperty(baseExpression, targetExpression).getExpressionString();
-    }
 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/strategy/JoinValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/strategy/JoinValidationStrategy.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/strategy/JoinValidationStrategy.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/strategy/JoinValidationStrategy.java Tue Nov  4 08:20:55 2008
@@ -21,11 +21,10 @@
 import org.apache.myfaces.extensions.validator.baseval.annotation.JoinValidation;
 import org.apache.myfaces.extensions.validator.baseval.annotation.extractor.DefaultPropertyScanningMetaDataExtractor;
 import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
-import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
 import org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractValidatorAdapter;
 import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
@@ -51,11 +50,13 @@
 
         ValidationStrategy validationStrategy;
 
+        TargetInformationEntry targetInformationEntry;
         for (String targetExpression : targetExpressions)
         {
-            targetExpression = createValidBinding(metaDataEntry, targetExpression);
+            targetInformationEntry = ExtValUtils
+                .createTargetInformationEntryForNewTarget(metaDataEntry, targetExpression);
 
-            for (MetaDataEntry entry : extractor.extract(facesContext, targetExpression).getMetaDataEntries())
+            for (MetaDataEntry entry : extractor.extract(facesContext, targetInformationEntry).getMetaDataEntries())
             {
                 validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
 
@@ -73,16 +74,4 @@
             }
         }
     }
-
-    private String createValidBinding(MetaDataEntry metaDataEntry, String targetExpression)
-    {
-        if(ExtValUtils.getELHelper().isELTerm(targetExpression))
-        {
-            return targetExpression;
-        }
-
-        ValueBindingExpression baseExpression = new ValueBindingExpression(
-            metaDataEntry.getProperty(PropertySourceInformationKeys.VALUE_BINDING_EXPRESSION, String.class));
-        return ValueBindingExpression.replaceOrAddProperty(baseExpression, targetExpression).getExpressionString();
-    }
 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java Tue Nov  4 08:20:55 2008
@@ -34,7 +34,6 @@
 {
     private MetaDataEntry metaDataEntry;
     //for complex components (e.g. a table) stores the object of entry (#{entry.property})
-    private Object bean;
     private UIComponent component;
     private Object convertedObject;
     private CrossValidationStrategy validationStrategy;
@@ -49,16 +48,6 @@
         this.metaDataEntry = metaDataEntry;
     }
 
-    public Object getBean()
-    {
-        return bean;
-    }
-
-    public void setBean(Object bean)
-    {
-        this.bean = bean;
-    }
-
     public UIComponent getComponent()
     {
         return component;

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=711295&r1=711294&r2=711295&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 Tue Nov  4 08:20:55 2008
@@ -19,7 +19,7 @@
 package org.apache.myfaces.extensions.validator.crossval.recorder;
 
 import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
 import org.apache.myfaces.extensions.validator.crossval.ProcessedInformationEntry;
 import org.apache.myfaces.extensions.validator.util.CrossValidationUtils;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
@@ -47,42 +47,42 @@
         }
 
         //to support local cross-validation (within the same entity)
-        Map<String, ProcessedInformationEntry> valueBindingConvertedValueMapping = CrossValidationUtils
-            .getOrInitValueBindingConvertedValueMapping();
+        Map<String, ProcessedInformationEntry> keyToConvertedValueMapping = CrossValidationUtils
+            .getOrInitKeyToConvertedValueMapping();
 
         ProcessedInformationEntry entry;
 
-        ValueBindingExpression vbe =
-            ExtValUtils.getELHelper().getValueBindingExpression(uiComponent);
+        TargetInformationEntry targetInformationEntry =
+            ExtValUtils.getELHelper().getTargetInformation(uiComponent);
 
-        if (vbe == null)
+        if(targetInformationEntry == null)
         {
             return;
         }
-
+        
         entry = new ProcessedInformationEntry();
-        entry.setBean(ExtValUtils.getELHelper().getBaseObject(vbe, uiComponent));
+        entry.setBean(targetInformationEntry.getBaseObject());
         entry.setConvertedValue(value);
         entry.setComponent(uiComponent);
 
-        String key = vbe.getExpressionString();
+        String key = targetInformationEntry.getKey();
 
         //for local cross-validation
-        if (valueBindingConvertedValueMapping.containsKey(key) &&
-            valueBindingConvertedValueMapping.get(key).getBean() != null &&
-            !valueBindingConvertedValueMapping.get(key).getBean().equals(entry.getBean()))
+        if (keyToConvertedValueMapping.containsKey(key) &&
+            keyToConvertedValueMapping.get(key).getBean() != null &&
+            !keyToConvertedValueMapping.get(key).getBean().equals(entry.getBean()))
         {
             //for the validation within a complex component e.g. a table
             //don't override existing expression (style: #{entry.property}) - make a special mapping
 
             List<ProcessedInformationEntry> furtherEntries =
-                valueBindingConvertedValueMapping.get(key).getFurtherEntries();
+                keyToConvertedValueMapping.get(key).getFurtherEntries();
 
             if (furtherEntries == null)
             {
                 furtherEntries = new ArrayList<ProcessedInformationEntry>();
 
-                valueBindingConvertedValueMapping.get(key).setFurtherEntries(furtherEntries);
+                keyToConvertedValueMapping.get(key).setFurtherEntries(furtherEntries);
             }
 
             furtherEntries.add(entry);
@@ -90,7 +90,7 @@
         else
         {
             //for normal validation
-            valueBindingConvertedValueMapping.put(key, entry);
+            keyToConvertedValueMapping.put(key, entry);
         }
     }
 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/ELCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/ELCompareStrategy.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/ELCompareStrategy.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/ELCompareStrategy.java Tue Nov  4 08:20:55 2008
@@ -78,7 +78,7 @@
 
             ProcessedInformationEntry validationTargetEntry;
             Map<String, ProcessedInformationEntry> valueBindingConvertedValueMapping = CrossValidationUtils
-                    .getOrInitValueBindingConvertedValueMapping();
+                    .getOrInitKeyToConvertedValueMapping();
 
             validationTargetEntry = valueBindingConvertedValueMapping
                     .get(validationTarget);

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalCompareStrategy.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalCompareStrategy.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalCompareStrategy.java Tue Nov  4 08:20:55 2008
@@ -23,15 +23,14 @@
 import org.apache.myfaces.extensions.validator.crossval.CrossValidationStorageEntry;
 import org.apache.myfaces.extensions.validator.crossval.strategy.AbstractCompareStrategy;
 import org.apache.myfaces.extensions.validator.util.CrossValidationUtils;
-import org.apache.myfaces.extensions.validator.util.ExtValUtils;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
-import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
+import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.faces.context.FacesContext;
 import java.util.Map;
 import java.lang.annotation.Annotation;
 
@@ -61,67 +60,75 @@
     protected boolean tryToValidateLocally(
             CrossValidationStorageEntry crossValidationStorageEntry,
             CrossValidationStorage crossValidationStorage,
-            String validationTarget,
+            String targetKey,
             AbstractCompareStrategy compareStrategy)
     {
-        String targetValueBindingExpression;
-
-        targetValueBindingExpression
-            = createTargetValueBindingExpression(crossValidationStorageEntry, validationTarget);
-
-        return targetValueBindingExpression != null &&
-            validateELExpression(crossValidationStorageEntry,
-                                 crossValidationStorage,
-                                 targetValueBindingExpression,
-                                 compareStrategy);
-
-    }
+        Map<String, ProcessedInformationEntry> keyConvertedValueMapping = CrossValidationUtils
+                .getOrInitKeyToConvertedValueMapping();
+        ProcessedInformationEntry validationTargetEntry;
 
-    protected String createTargetValueBindingExpression(CrossValidationStorageEntry crossValidationStorageEntry,
-                                                        String validationTarget)
-    {
-        ValueBindingExpression baseExpression =
-            new ValueBindingExpression(crossValidationStorageEntry.getMetaDataEntry()
-                .getProperty(PropertySourceInformationKeys.VALUE_BINDING_EXPRESSION, String.class));
-        return ValueBindingExpression.replaceOrAddProperty(baseExpression, validationTarget).getExpressionString();
-    }
+        TargetInformationEntry targetInformationEntry = crossValidationStorageEntry.getMetaDataEntry()
+                .getProperty(PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY, TargetInformationEntry.class);
 
-    protected boolean validateELExpression(CrossValidationStorageEntry crossValidationStorageEntry,
-                                           CrossValidationStorage crossValidationStorage,
-                                           String validationTarget,
-                                           AbstractCompareStrategy compareStrategy)
-    {
-        if (!ExtValUtils.getELHelper().isExpressionValid(FacesContext.getCurrentInstance(), validationTarget))
+        String newKey = createTargetKey(crossValidationStorageEntry, targetKey);
+        if (!keyConvertedValueMapping.containsKey(newKey))
         {
-            throw new IllegalStateException(
-                "invalid reference used: "
-                + validationTarget
-                + " please check your extval annotations");
+            return false;
         }
 
-        boolean violationFound = false;
-        Map<String, ProcessedInformationEntry> valueBindingConvertedValueMapping = CrossValidationUtils
-                .getOrInitValueBindingConvertedValueMapping();
-        ProcessedInformationEntry validationTargetEntry;
+        String sourceKey = targetInformationEntry.getKey();
 
-        if (!valueBindingConvertedValueMapping.containsKey(validationTarget))
+        if(!sourceKey.contains("."))
         {
-            return false;
+            throw new IllegalStateException("source path: " + sourceKey + " invalid");
         }
+
+        targetKey = sourceKey.substring(0, sourceKey.lastIndexOf(".") + 1) + targetKey;
+
         validationTargetEntry = compareStrategy.resolveValidationTargetEntry(
-                valueBindingConvertedValueMapping,
-                validationTarget, crossValidationStorageEntry.getBean());
+                keyConvertedValueMapping, targetKey, crossValidationStorageEntry);
 
         if (validationTargetEntry == null)
         {
             if(logger.isWarnEnabled())
             {
-                logger.warn("couldn't find converted object for " + validationTarget);
+                logger.warn("couldn't find converted object for " + targetInformationEntry.getKey());
             }
 
             return false;
         }
 
+        return tryToValidateLocally(
+            crossValidationStorageEntry,
+            crossValidationStorage,
+            targetKey,
+            compareStrategy,
+            validationTargetEntry);
+    }
+
+    protected String createTargetKey(CrossValidationStorageEntry crossValidationStorageEntry, String targetKey)
+    {
+        //no real value binding expression
+        //ValueBindingExpression just hepls to replace the property of the key
+        //here only dot-notation is allowed -> no problem
+        ValueBindingExpression baseExpression =
+            new ValueBindingExpression("#{" + crossValidationStorageEntry.getMetaDataEntry()
+                .getProperty(PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY,
+                    TargetInformationEntry.class).getKey() + "}");
+
+        String result = ValueBindingExpression.replaceOrAddProperty(baseExpression, targetKey)
+            .getExpressionString();
+        return result.substring(2, result.length() -1);
+    }
+
+    protected boolean tryToValidateLocally(CrossValidationStorageEntry crossValidationStorageEntry,
+            CrossValidationStorage crossValidationStorage,
+            String targetKey,
+            AbstractCompareStrategy compareStrategy,
+            ProcessedInformationEntry validationTargetEntry)
+    {
+        boolean violationFound = false;
+
         if (compareStrategy.isViolation(crossValidationStorageEntry
                 .getConvertedObject(), validationTargetEntry
                 .getConvertedValue(), crossValidationStorageEntry

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalPropertyChainCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalPropertyChainCompareStrategy.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalPropertyChainCompareStrategy.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/LocalPropertyChainCompareStrategy.java Tue Nov  4 08:20:55 2008
@@ -23,6 +23,12 @@
 import org.apache.myfaces.extensions.validator.crossval.strategy.AbstractCompareStrategy;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
+import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 
 /**
  * "[local_property.property1.property2]"
@@ -33,15 +39,66 @@
 @UsageInformation(UsageCategory.INTERNAL)
 public class LocalPropertyChainCompareStrategy extends LocalCompareStrategy
 {
-    protected boolean validateELExpression(CrossValidationStorageEntry crossValidationStorageEntry,
+    @Override
+    protected boolean tryToValidateLocally(CrossValidationStorageEntry crossValidationStorageEntry,
                                            CrossValidationStorage crossValidationStorage,
-                                           String validationTarget,
+                                           String targetKey,
                                            AbstractCompareStrategy compareStrategy)
     {
-        return new ELCompareStrategy().evalReferenceAndValidate(
-            crossValidationStorageEntry,
-            crossValidationStorage,
-            validationTarget,
-            compareStrategy);
+        TargetInformationEntry targetInformationEntry = crossValidationStorageEntry.getMetaDataEntry()
+            .getProperty(PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY, TargetInformationEntry.class);
+
+        Object newBase = ReflectionUtils
+            .getBaseOfPropertyChain(targetInformationEntry.getBaseObject(), targetKey);
+
+        if(targetKey.contains("."))
+        {
+            //find the last property
+            targetKey = targetKey.substring(targetKey.lastIndexOf(".") + 1, targetKey.length());
+        }
+
+        Object targetValue = getValueOfProperty(newBase, targetKey);
+
+        boolean violationFound = false;
+
+        if (compareStrategy.isViolation(crossValidationStorageEntry.getConvertedObject(),
+                                targetValue, crossValidationStorageEntry.getMetaDataEntry().getValue(Annotation.class)))
+        {
+
+            CrossValidationStorageEntry tmpCrossValidationStorageEntry = new CrossValidationStorageEntry();
+            tmpCrossValidationStorageEntry.setComponent(crossValidationStorageEntry.getComponent());
+            tmpCrossValidationStorageEntry.setConvertedObject(targetValue);
+            tmpCrossValidationStorageEntry.setValidationStrategy(compareStrategy);
+
+            compareStrategy
+                    .processTargetComponentAfterViolation(crossValidationStorageEntry, tmpCrossValidationStorageEntry);
+
+            violationFound = true;
+        }
+
+        if (violationFound)
+        {
+            compareStrategy.processSourceComponentAfterViolation(crossValidationStorageEntry);
+        }
+
+        return true;
+    }
+
+    private Object getValueOfProperty(Object base, String property)
+    {
+        property = property.substring(0,1).toUpperCase() + property.substring(1, property.length());
+        Method targetMethod = ReflectionUtils.tryToGetMethod(base.getClass(), "get" + property);
+
+        if(targetMethod == null)
+        {
+            targetMethod = ReflectionUtils.tryToGetMethod(base.getClass(), "is" + property);
+        }
+
+        if(targetMethod == null)
+        {
+            throw new IllegalStateException(
+                "class " + base.getClass() + " has no public get/is " + property.toLowerCase());
+        }
+        return ReflectionUtils.tryToInvokeMethod(base, targetMethod);
     }
 }
\ No newline at end of file

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java Tue Nov  4 08:20:55 2008
@@ -39,6 +39,8 @@
 import org.apache.myfaces.extensions.validator.util.ClassUtils;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
 import org.apache.myfaces.extensions.validator.core.CustomInfo;
+import org.apache.myfaces.extensions.validator.core.el.TargetInformationEntry;
+import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 
@@ -84,13 +86,11 @@
 
     public void processCrossValidation(
             CrossValidationStorageEntry crossValidationStorageEntry,
-            CrossValidationStorage crossValidationStorage)
-            throws ValidatorException
+            CrossValidationStorage crossValidationStorage) throws ValidatorException
     {
-
         initValidation(crossValidationStorageEntry);
-        String[] validationTargets = getValidationTargets(crossValidationStorageEntry
-                .getMetaDataEntry().getValue(Annotation.class));
+        String[] validationTargets = getValidationTargets(
+            crossValidationStorageEntry.getMetaDataEntry().getValue(Annotation.class));
 
         for (String validationTarget : validationTargets)
         {
@@ -189,8 +189,7 @@
     }
 
     //has to be public for custom referencing strategies!!!
-    public FacesMessage getSourceComponentErrorMessage(Annotation annotation,
-            String summary, String details)
+    public FacesMessage getSourceComponentErrorMessage(Annotation annotation, String summary, String details)
     {
         FacesMessage message = new FacesMessage();
 
@@ -202,8 +201,7 @@
     }
 
     //has to be public for custom referencing strategies!!!
-    public FacesMessage getTargetComponentErrorMessage(
-            Annotation foundAnnotation, String summary, String details)
+    public FacesMessage getTargetComponentErrorMessage(Annotation foundAnnotation, String summary, String details)
     {
         FacesMessage message = new FacesMessage();
 
@@ -216,11 +214,11 @@
 
     //has to be public for custom referencing strategies!!!
     public ProcessedInformationEntry resolveValidationTargetEntry(
-            Map<String, ProcessedInformationEntry> valueBindingConvertedValueMapping,
-            String targetValueBinding, Object bean)
+            Map<String, ProcessedInformationEntry> pathToConvertedValueMapping,
+            String targetKey, CrossValidationStorageEntry crossValidationStorageEntry)
     {
-        ProcessedInformationEntry processedInformationEntry = valueBindingConvertedValueMapping
-                .get(targetValueBinding);
+        ProcessedInformationEntry processedInformationEntry =
+            pathToConvertedValueMapping.get(targetKey);
 
         //simple case
         if (processedInformationEntry.getFurtherEntries() == null)
@@ -228,16 +226,21 @@
             return processedInformationEntry;
         }
 
+        TargetInformationEntry targetInformationEntry = crossValidationStorageEntry.getMetaDataEntry()
+                .getProperty(PropertySourceInformationKeys.TARGET_INFORMATION_ENTRY, TargetInformationEntry.class);
+
+        Object targetBean = targetInformationEntry.getBaseObject();
+
         //process complex component entries (e.g. a table)
         //supported: cross-component but no cross-entity validation (= locale validation)
-        if (processedInformationEntry.getBean().equals(bean))
+        if (processedInformationEntry.getBean().equals(targetBean))
         {
             return processedInformationEntry;
         }
 
         for (ProcessedInformationEntry entry : processedInformationEntry.getFurtherEntries())
         {
-            if (entry.getBean().equals(bean))
+            if (entry.getBean().equals(targetBean))
             {
                 return entry;
             }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java Tue Nov  4 08:20:55 2008
@@ -18,13 +18,10 @@
  */
 package org.apache.myfaces.extensions.validator.crossval.strategy;
 
-import org.apache.myfaces.extensions.validator.core.metadata.PropertySourceInformationKeys;
 import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
 import org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractAnnotationValidationStrategy;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
 import org.apache.myfaces.extensions.validator.crossval.CrossValidationStorageEntry;
 import org.apache.myfaces.extensions.validator.util.CrossValidationUtils;
-import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 
@@ -40,14 +37,12 @@
 public abstract class AbstractCrossValidationStrategy extends
     AbstractAnnotationValidationStrategy implements CrossValidationStrategy
 {
-
     //init cross-validation
     public void processValidation(FacesContext facesContext,
-            UIComponent uiComponent, MetaDataEntry metaDataEntry,
-            Object convertedObject) throws ValidatorException
+            UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject) throws ValidatorException
     {
-        CrossValidationStorageEntry entry = getCrossValidationStorageEntry(
-                facesContext, uiComponent, metaDataEntry, convertedObject);
+        CrossValidationStorageEntry entry =
+            getCrossValidationStorageEntry(facesContext, uiComponent, metaDataEntry, convertedObject);
 
         CrossValidationUtils.getOrInitCrossValidationStorage().add(entry);
     }
@@ -59,8 +54,6 @@
         CrossValidationStorageEntry entry = new CrossValidationStorageEntry();
 
         entry.setMetaDataEntry(metaDataEntry);
-        String vbe = metaDataEntry.getProperty(PropertySourceInformationKeys.VALUE_BINDING_EXPRESSION, String.class);
-        entry.setBean(ExtValUtils.getELHelper().getBaseObject(new ValueBindingExpression(vbe)));
         entry.setComponent(uiComponent);
         entry.setConvertedObject(convertedObject);
         entry.setValidationStrategy(this);

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/util/CrossValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/util/CrossValidationUtils.java?rev=711295&r1=711294&r2=711295&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/util/CrossValidationUtils.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/util/CrossValidationUtils.java Tue Nov  4 08:20:55 2008
@@ -57,23 +57,23 @@
                 .put(CROSS_VALIDATION_STORAGE_KEY, new CrossValidationStorage());
     }
 
-    public static final String VALUE_BINDING_CONVERTED_VALUE_MAPPING_KEY = JsfUtils.class.getName();
+    public static final String KEY_TO_CONVERTED_VALUE_MAPPING_KEY = JsfUtils.class.getName();
 
-    public static Map<String, ProcessedInformationEntry> getOrInitValueBindingConvertedValueMapping()
+    public static Map<String, ProcessedInformationEntry> getOrInitKeyToConvertedValueMapping()
     {
         Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
 
-        if (!requestMap.containsKey(VALUE_BINDING_CONVERTED_VALUE_MAPPING_KEY))
+        if (!requestMap.containsKey(KEY_TO_CONVERTED_VALUE_MAPPING_KEY))
         {
-            resetValueBindingConvertedValueMapping();
+            resetKeyToConvertedValueMapping();
         }
 
-        return (Map<String, ProcessedInformationEntry>) requestMap.get(VALUE_BINDING_CONVERTED_VALUE_MAPPING_KEY);
+        return (Map<String, ProcessedInformationEntry>) requestMap.get(KEY_TO_CONVERTED_VALUE_MAPPING_KEY);
     }
 
-    public static void resetValueBindingConvertedValueMapping()
+    public static void resetKeyToConvertedValueMapping()
     {
         FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
-            .put(VALUE_BINDING_CONVERTED_VALUE_MAPPING_KEY, new HashMap<String, ProcessedInformationEntry>());
+            .put(KEY_TO_CONVERTED_VALUE_MAPPING_KEY, new HashMap<String, ProcessedInformationEntry>());
     }
 }



Mime
View raw message