myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r778236 [1/2] - in /myfaces/extensions/validator/branches/branch_for_jsf_2: core/src/main/java/org/apache/myfaces/extensions/validator/core/ core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ core/src/main/java/org...
Date Sun, 24 May 2009 21:12:15 GMT
Author: gpetracek
Date: Sun May 24 21:12:14 2009
New Revision: 778236

URL: http://svn.apache.org/viewvc?rev=778236&view=rev
Log:
sync issue 42 and additions for jsf 2.0

Added:
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationRendererInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ValidationGroupProvider.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/startup/JSF2AwareBeanValidationStartupListener.java
Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/CustomInformation.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/InformationProviderBean.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/startup/BeanValidationStartupListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/PropertyValidationModuleStartupListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/ValidationInterceptorWithSkipValidationSupport.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/CustomInformation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/CustomInformation.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/CustomInformation.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/CustomInformation.java Sun May 24 21:12:14 2009
@@ -42,6 +42,7 @@
     STARTUP_LISTENER,
     COMPONENT_INITIALIZER,
     VALIDATION_EXCEPTION_INTERCEPTOR,
+    VALIDATION_INTERCEPTOR,
     META_DATA_EXTRACTION_INTERCEPTOR,
 
     MESSAGE_RESOLVER_FACTORY,

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java Sun May 24 21:12:14 2009
@@ -23,6 +23,7 @@
 import org.apache.myfaces.extensions.validator.core.interceptor.RendererInterceptor;
 import org.apache.myfaces.extensions.validator.core.interceptor.ValidationExceptionInterceptor;
 import org.apache.myfaces.extensions.validator.core.interceptor.MetaDataExtractionInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationInterceptor;
 import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
 import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
 import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
@@ -59,6 +60,7 @@
 
     private List<ComponentInitializer> componentInitializers;
     private List<ValidationExceptionInterceptor> validationExceptionInterceptors;
+    private List<ValidationInterceptor> validationInterceptors;
     private List<MetaDataExtractionInterceptor> metaDataExtractionInterceptors;
 
     private Map<String, Object> globalProperties = new HashMap<String, Object>();
@@ -134,6 +136,41 @@
         }
     }
 
+    private void lazyInitValidationInterceptors()
+    {
+        if(this.validationInterceptors != null)
+        {
+            return;
+        }
+
+        this.validationInterceptors = new ArrayList<ValidationInterceptor>();
+        List<String> validationInterceptorClassNames = new ArrayList<String>();
+
+        validationInterceptorClassNames
+            .add(WebXmlParameter.CUSTOM_VALIDATION_INTERCEPTOR);
+        validationInterceptorClassNames
+            .add(ExtValContext.getContext().getInformationProviderBean().get(
+                    CustomInformation.VALIDATION_INTERCEPTOR));
+
+        ValidationInterceptor validationInterceptor;
+        for (String validationInterceptorName : validationInterceptorClassNames)
+        {
+            validationInterceptor =
+                (ValidationInterceptor)
+                        ClassUtils.tryToInstantiateClassForName(validationInterceptorName);
+
+            if (validationInterceptor != null)
+            {
+                validationInterceptors.add(validationInterceptor);
+
+                if(logger.isTraceEnabled())
+                {
+                    logger.trace(validationInterceptor.getClass().getName() + " added");
+                }
+            }
+        }
+    }
+
     private void lazyInitMetaDataExtractionInterceptors()
     {
         if(this.metaDataExtractionInterceptors != null)
@@ -252,7 +289,19 @@
     public List<ValidationExceptionInterceptor> getValidationExceptionInterceptors()
     {
         lazyInitValidationExceptionInterceptors();
-        return validationExceptionInterceptors;
+        return this.validationExceptionInterceptors;
+    }
+
+    public void addValidationInterceptor(ValidationInterceptor validationInterceptor)
+    {
+        lazyInitValidationInterceptors();
+        this.validationInterceptors.add(validationInterceptor);
+    }
+
+    public List<ValidationInterceptor> getValidationValidationInterceptors()
+    {
+        lazyInitValidationInterceptors();
+        return this.validationInterceptors;
     }
 
     public void addMetaDataExtractionInterceptor(MetaDataExtractionInterceptor metaDataExtractionInterceptor)

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/InformationProviderBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/InformationProviderBean.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/InformationProviderBean.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/InformationProviderBean.java Sun May 24 21:12:14 2009
@@ -90,6 +90,8 @@
                 "ComponentInitializer");
         customizableInfos.put(CustomInformation.VALIDATION_EXCEPTION_INTERCEPTOR,
                 "ValidationExceptionInterceptor");
+        customizableInfos.put(CustomInformation.VALIDATION_INTERCEPTOR,
+                "ValidationInterceptor");
         customizableInfos.put(CustomInformation.META_DATA_EXTRACTION_INTERCEPTOR,
                 "MetaDataExtractionInterceptor");
 

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java Sun May 24 21:12:14 2009
@@ -55,6 +55,9 @@
     static final String CUSTOM_VALIDATION_EXCEPTION_INTERCEPTOR = WebXmlUtils
         .getInitParameter("CUSTOM_VALIDATION_EXCEPTION_INTERCEPTOR");
 
+    static final String CUSTOM_VALIDATION_INTERCEPTOR = WebXmlUtils
+        .getInitParameter("CUSTOM_VALIDATION_INTERCEPTOR");
+
     static final String CUSTOM_META_DATA_EXTRACTION_INTERCEPTOR = WebXmlUtils
         .getInitParameter("CUSTOM_META_DATA_EXTRACTION_INTERCEPTOR");
 

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java Sun May 24 21:12:14 2009
@@ -1,217 +1,51 @@
-/*
- * 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.interceptor;
-
-import org.apache.myfaces.extensions.validator.internal.UsageCategory;
-import org.apache.myfaces.extensions.validator.internal.UsageInformation;
-import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
-import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
-import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
-import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
-import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
-import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
-import org.apache.myfaces.extensions.validator.core.ExtValContext;
-import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipBeforeInterceptorsException;
-import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipRendererDelegationException;
-import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
-import org.apache.myfaces.extensions.validator.util.ExtValUtils;
-
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.convert.ConverterException;
-import javax.faces.render.Renderer;
-import javax.faces.validator.ValidatorException;
-import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author Gerhard Petracek
- * @since 1.x.1
- */
-@UsageInformation(UsageCategory.INTERNAL)
-public class ValidationInterceptor extends AbstractRendererInterceptor
-{
-    @Override
-    public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
-            throws IOException, SkipBeforeInterceptorsException, SkipRendererDelegationException
-    {
-        initComponent(facesContext, uiComponent);
-    }
-
-    protected void initComponent(FacesContext facesContext, UIComponent uiComponent)
-    {
-        if(!(uiComponent instanceof EditableValueHolder))
-        {
-            return;
-        }
-
-        if(logger.isTraceEnabled())
-        {
-            logger.trace("start to init component " + uiComponent.getClass().getName());
-        }
-
-        ValidationStrategy validationStrategy;
-        MetaDataTransformer metaDataTransformer;
-
-        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
-
-        Map<String, Object> metaData = new HashMap<String, Object>();
-        for (MetaDataEntry entry : metaDataExtractor.extract(facesContext, uiComponent).getMetaDataEntries())
-        {
-            validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
-
-            if (validationStrategy != null)
-            {
-                if(!skipValidation(facesContext, uiComponent, validationStrategy, entry))
-                {
-                    metaDataTransformer = ExtValUtils.getMetaDataTransformerForValidationStrategy(validationStrategy);
-
-                    if(metaDataTransformer != null)
-                    {
-                        if(this.logger.isDebugEnabled())
-                        {
-                            this.logger.debug(metaDataTransformer.getClass().getName() + " instantiated");
-                        }
-                        
-                        metaData = metaDataTransformer.convertMetaData(entry);
-                    }
-                    else
-                    {
-                        metaData = null;
-                    }
-
-                    if(metaData == null)
-                    {
-                        metaData = new HashMap<String, Object>();
-                    }
-                }
-
-                if(!metaData.isEmpty() &&
-                        Boolean.TRUE.equals(entry.getProperty(PropertyInformationKeys.SKIP_VALIDATION, Boolean.class)))
-                {
-                    metaData.put(CommonMetaDataKeys.SKIP_VALIDATION, true);
-                }
-
-                //get component initializer for the current component and configure it
-                //also in case of skipped validation to reset e.g. the required attribute
-                if(!metaData.isEmpty())
-                {
-                    ExtValUtils.configureComponentWithMetaData(facesContext, uiComponent, metaData);
-                }
-           }
-        }
-
-        if(logger.isTraceEnabled())
-        {
-            logger.trace("init component of " + uiComponent.getClass().getName() + " finished");
-        }
-    }
-
-    @Override
-    public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
-            throws ConverterException, SkipBeforeInterceptorsException, SkipRendererDelegationException
-    {
-        Object convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
-
-        //recorde user input e.g. for cross-component validation
-        for(ProcessedInformationRecorder recorder : ExtValContext.getContext().getProcessedInformationRecorders())
-        {
-            recorder.recordUserInput(uiComponent, convertedObject);
-
-            if(logger.isTraceEnabled())
-            {
-                logger.trace(recorder.getClass().getName() + " called");
-            }
-        }
-
-        try
-        {
-            processValidation(facesContext, uiComponent, convertedObject);
-        }
-        catch (ValidatorException e)
-        {
-            throw new ConverterException(e.getFacesMessage(), e);
-        }
-    }
-
-    protected void processValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject)
-    {
-        if (!(uiComponent instanceof EditableValueHolder))
-        {
-            return;
-        }
-
-        if(logger.isTraceEnabled())
-        {
-            logger.trace("start validation");
-        }
-
-        ValidationStrategy validationStrategy;
-
-        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
-
-        for (MetaDataEntry entry : metaDataExtractor.extract(facesContext, uiComponent).getMetaDataEntries())
-        {
-            validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
-
-            if (validationStrategy != null)
-            {
-                if(skipValidation(facesContext, uiComponent, validationStrategy, entry))
-                {
-                    //required is a special case - reset it
-                    ((EditableValueHolder)uiComponent).setRequired(false);
-
-                    continue;
-                }
-
-                if(logger.isTraceEnabled())
-                {
-                    logger.trace("validate " + entry.getValue() + " with " +
-                            validationStrategy.getClass().getName());
-                }
-
-                validationStrategy.validate(facesContext, uiComponent, entry, convertedObject);
-            }
-            else
-            {
-                if(logger.isTraceEnabled())
-                {
-                    logger.trace("no validation strategy found for "
-                            + entry.getValue());
-                }
-            }
-        }
-
-        if(logger.isTraceEnabled())
-        {
-            logger.trace("validation finished");
-        }
-    }
-
-    protected boolean skipValidation(FacesContext facesContext,
-                                     UIComponent uiComponent,
-                                     ValidationStrategy validationStrategy,
-                                     MetaDataEntry entry)
-    {
-        //override for custom skip validation support (if needed)
-        return false;
-    }
-}
+/*
+ * 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.interceptor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface ValidationInterceptor
+{
+    /**
+     * @return false if the validation process should be bypassed
+     */
+    boolean beforeValidation(FacesContext facesContext,
+                             UIComponent uiComponent,
+                             Object convertedObject,
+                             Map<String, Object> properties);
+
+    /**
+     * processed if validation was executed
+     * in contrast to ValidationExceptionInterceptor it gets executed in any case
+     */
+    void afterValidation(FacesContext facesContext,
+                         UIComponent uiComponent,
+                         Object convertedObject,
+                         Map<String, Object> properties);
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationRendererInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationRendererInterceptor.java?rev=778236&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationRendererInterceptor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationRendererInterceptor.java Sun May 24 21:12:14 2009
@@ -0,0 +1,239 @@
+/*
+ * 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.interceptor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipBeforeInterceptorsException;
+import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipRendererDelegationException;
+import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.convert.ConverterException;
+import javax.faces.render.Renderer;
+import javax.faces.validator.ValidatorException;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class ValidationRendererInterceptor extends AbstractRendererInterceptor
+{
+    @Override
+    public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+            throws IOException, SkipBeforeInterceptorsException, SkipRendererDelegationException
+    {
+        initComponent(facesContext, uiComponent);
+    }
+
+    protected void initComponent(FacesContext facesContext, UIComponent uiComponent)
+    {
+        if(!(uiComponent instanceof EditableValueHolder))
+        {
+            return;
+        }
+
+        if(logger.isTraceEnabled())
+        {
+            logger.trace("start to init component " + uiComponent.getClass().getName());
+        }
+
+        ValidationStrategy validationStrategy;
+        MetaDataTransformer metaDataTransformer;
+
+        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
+
+        Map<String, Object> metaData = new HashMap<String, Object>();
+        for (MetaDataEntry entry : metaDataExtractor.extract(facesContext, uiComponent).getMetaDataEntries())
+        {
+            validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
+
+            if (validationStrategy != null)
+            {
+                if(!skipValidation(facesContext, uiComponent, validationStrategy, entry))
+                {
+                    metaDataTransformer = ExtValUtils.getMetaDataTransformerForValidationStrategy(validationStrategy);
+
+                    if(metaDataTransformer != null)
+                    {
+                        if(this.logger.isDebugEnabled())
+                        {
+                            this.logger.debug(metaDataTransformer.getClass().getName() + " instantiated");
+                        }
+                        
+                        metaData = metaDataTransformer.convertMetaData(entry);
+                    }
+                    else
+                    {
+                        metaData = null;
+                    }
+
+                    if(metaData == null)
+                    {
+                        metaData = new HashMap<String, Object>();
+                    }
+                }
+
+                if(!metaData.isEmpty() &&
+                        Boolean.TRUE.equals(entry.getProperty(PropertyInformationKeys.SKIP_VALIDATION, Boolean.class)))
+                {
+                    metaData.put(CommonMetaDataKeys.SKIP_VALIDATION, true);
+                }
+
+                //get component initializer for the current component and configure it
+                //also in case of skipped validation to reset e.g. the required attribute
+                if(!metaData.isEmpty())
+                {
+                    ExtValUtils.configureComponentWithMetaData(facesContext, uiComponent, metaData);
+                }
+           }
+        }
+
+        if(logger.isTraceEnabled())
+        {
+            logger.trace("init component of " + uiComponent.getClass().getName() + " finished");
+        }
+    }
+
+    @Override
+    public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
+            throws ConverterException, SkipBeforeInterceptorsException, SkipRendererDelegationException
+    {
+        Object convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+
+        //recorde user input e.g. for cross-component validation
+        for(ProcessedInformationRecorder recorder : ExtValContext.getContext().getProcessedInformationRecorders())
+        {
+            recorder.recordUserInput(uiComponent, convertedObject);
+
+            if(logger.isTraceEnabled())
+            {
+                logger.trace(recorder.getClass().getName() + " called");
+            }
+        }
+
+        try
+        {
+            processValidation(facesContext, uiComponent, convertedObject);
+        }
+        catch (ValidatorException e)
+        {
+            throw new ConverterException(e.getFacesMessage(), e);
+        }
+    }
+
+    protected void processValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject)
+    {
+        if (!(uiComponent instanceof EditableValueHolder))
+        {
+            return;
+        }
+
+        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
+
+        PropertyInformation propertyInformation = metaDataExtractor.extract(facesContext, uiComponent);
+
+        if(!ExtValUtils.executeBeforeValidationInterceptors(facesContext, uiComponent, convertedObject,
+                PropertyInformation.class.getName() ,propertyInformation))
+        {
+            return;
+        }
+
+        try
+        {
+            if(logger.isTraceEnabled())
+            {
+                logger.trace("start validation");
+            }
+
+            processFieldValidation(facesContext, uiComponent, convertedObject, propertyInformation);
+
+            if(logger.isTraceEnabled())
+            {
+                logger.trace("validation finished");
+            }
+        }
+        finally
+        {
+            ExtValUtils.executeAfterValidationInterceptors(facesContext, uiComponent, convertedObject,
+                    PropertyInformation.class.getName(), propertyInformation);
+        }
+    }
+
+    protected void processFieldValidation(FacesContext facesContext,
+                                          UIComponent uiComponent,
+                                          Object convertedObject,
+                                          PropertyInformation propertyInformation)
+    {
+        ValidationStrategy validationStrategy;
+        for (MetaDataEntry entry : propertyInformation.getMetaDataEntries())
+        {
+            validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
+
+            if (validationStrategy != null)
+            {
+                if(skipValidation(facesContext, uiComponent, validationStrategy, entry))
+                {
+                    //required is a special case - reset it
+                    ((EditableValueHolder)uiComponent).setRequired(false);
+
+                    continue;
+                }
+
+                if(logger.isTraceEnabled())
+                {
+                    logger.trace("validate " + entry.getValue() + " with " + validationStrategy.getClass().getName());
+                }
+
+                validationStrategy.validate(facesContext, uiComponent, entry, convertedObject);
+            }
+            else
+            {
+                if(logger.isTraceEnabled())
+                {
+                    logger.trace("no validation strategy found for " + entry.getValue());
+                }
+            }
+        }
+    }
+
+    protected boolean skipValidation(FacesContext facesContext,
+                                     UIComponent uiComponent,
+                                     ValidationStrategy validationStrategy,
+                                     MetaDataEntry entry)
+    {
+        //override for custom skip validation support (if needed)
+        return false;
+    }
+}

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java Sun May 24 21:12:14 2009
@@ -20,7 +20,7 @@
 
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
-import org.apache.myfaces.extensions.validator.core.interceptor.ValidationInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationRendererInterceptor;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
 import org.apache.myfaces.extensions.validator.core.CustomInformation;
 import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
@@ -80,7 +80,7 @@
             }
         }
 
-        ExtValContext.getContext().registerRendererInterceptor(new ValidationInterceptor());
+        ExtValContext.getContext().registerRendererInterceptor(new ValidationRendererInterceptor());
 
         ExtValContext.getContext()
                 .addGlobalProperty(ExtValRendererProxy.KEY, ExtValRendererProxy.class.getName(), false);

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java Sun May 24 21:12:14 2009
@@ -27,6 +27,7 @@
 import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
 import org.apache.myfaces.extensions.validator.core.interceptor.ValidationExceptionInterceptor;
 import org.apache.myfaces.extensions.validator.core.interceptor.MetaDataExtractionInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationInterceptor;
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
 import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
@@ -52,6 +53,7 @@
 import javax.faces.validator.ValidatorException;
 import javax.faces.application.FacesMessage;
 import java.util.Map;
+import java.util.HashMap;
 import java.util.MissingResourceException;
 import java.util.List;
 import java.util.ArrayList;
@@ -419,4 +421,53 @@
 
         return false;
     }
+
+    public static boolean executeBeforeValidationInterceptors(FacesContext facesContext,
+                                                              UIComponent uiComponent,
+                                                              Object convertedObject,
+                                                              String propertyKey,
+                                                              Object properties)
+    {
+        Map<String, Object> propertyMap = new HashMap<String, Object>();
+
+        if(properties != null)
+        {
+            propertyMap.put(propertyKey, properties);
+        }
+        
+        List<ValidationInterceptor> validationInterceptors =
+                ExtValContext.getContext().getValidationValidationInterceptors();
+
+        for(ValidationInterceptor validationInterceptor : validationInterceptors)
+        {
+            if(!validationInterceptor.beforeValidation(facesContext, uiComponent, convertedObject, propertyMap))
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static void executeAfterValidationInterceptors(FacesContext facesContext,
+                                                          UIComponent uiComponent,
+                                                          Object convertedObject,
+                                                          String propertyKey,
+                                                          Object properties)
+    {
+        Map<String, Object> propertyMap = new HashMap<String, Object>();
+
+        if(properties != null)
+        {
+            propertyMap.put(propertyKey, properties);
+        }
+
+        List<ValidationInterceptor> validationInterceptors =
+                ExtValContext.getContext().getValidationValidationInterceptors();
+
+        for(ValidationInterceptor validationInterceptor : validationInterceptors)
+        {
+            validationInterceptor.afterValidation(facesContext, uiComponent, convertedObject, propertyMap);
+        }
+    }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README Sun May 24 21:12:14 2009
@@ -3,4 +3,8 @@
  - ExtValRenderKit
  - BeanValidationInterceptor (isValidationDisabled, mergeFoundGroupsWithValidatorGroups)
  - DefaultELHelper
- - ExtValELResolver
\ No newline at end of file
+ - ExtValELResolver
+ - ExtValBeanValidator
+ - ResetBeanValidationRendererInterceptor
+ - BeanValidationTagAwareValidationInterceptor
+ - JSF2AwareBeanValidationStartupListener

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml Sun May 24 21:12:14 2009
@@ -24,6 +24,7 @@
         <application-factory>org.apache.myfaces.extensions.validator.beanval.factory.ExtValApplicationFactory</application-factory>
     </factory>
     <lifecycle>
+        <phase-listener>org.apache.myfaces.extensions.validator.beanval.startup.JSF2AwareBeanValidationStartupListener</phase-listener>
         <phase-listener>org.apache.myfaces.extensions.validator.beanval.startup.BeanValidationStartupListener</phase-listener>
         <phase-listener>org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationPhaseListener</phase-listener>
     </lifecycle>

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java Sun May 24 21:12:14 2009
@@ -23,8 +23,6 @@
 import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
 import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
-import org.apache.myfaces.extensions.validator.core.el.ELHelper;
-import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
 import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
@@ -34,17 +32,12 @@
 import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
 import org.apache.myfaces.extensions.validator.core.interceptor.AbstractRendererInterceptor;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
-import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
-import org.apache.myfaces.extensions.validator.util.ClassUtils;
 import org.apache.myfaces.extensions.validator.beanval.property.BeanValidationPropertyInformationKeys;
-import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
-import org.apache.myfaces.extensions.validator.beanval.annotation.ModelValidation;
-import org.apache.myfaces.extensions.validator.beanval.annotation.extractor.DefaultGroupControllerScanningExtractor;
 import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationStrategyAdapter;
-import org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationEntry;
-import org.apache.myfaces.extensions.validator.beanval.annotation.NoRestrictionGroup;
 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 javax.faces.context.FacesContext;
 import javax.faces.component.UIComponent;
@@ -52,8 +45,6 @@
 import javax.faces.render.Renderer;
 import javax.faces.convert.ConverterException;
 import javax.faces.validator.ValidatorException;
-import javax.faces.validator.Validator;
-import javax.faces.validator.BeanValidator;
 import javax.faces.application.FacesMessage;
 import javax.validation.Validation;
 import javax.validation.BeanDescriptor;
@@ -61,20 +52,16 @@
 import javax.validation.ConstraintDescriptor;
 import javax.validation.ValidatorFactory;
 import javax.validation.ConstraintViolation;
-import javax.validation.groups.Default;
 import java.util.Set;
 import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.io.IOException;
-import java.lang.reflect.Method;
 
 /**
  * @author Gerhard Petracek
- * @since 1.x.3
+ * @since x.x.3
  */
 @ToDo(value = Priority.HIGH, description = "sync jsf 2.0 specific changes with bv-branch")
+@UsageInformation(UsageCategory.INTERNAL)
 public class BeanValidationInterceptor extends AbstractRendererInterceptor
 {
     private ValidatorFactory validationFactory = Validation.buildDefaultValidatorFactory();
@@ -97,15 +84,9 @@
             logger.trace("start to init component " + uiComponent.getClass().getName());
         }
 
-        if(isValidationDisabled(((EditableValueHolder)uiComponent).getValidators()))
-        {
-            return;
-        }
-
         MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
 
-        PropertyInformation propertyInformation = metaDataExtractor.extract(facesContext, uiComponent);
-        PropertyDetails propertyDetails = propertyInformation
+        PropertyDetails propertyDetails = metaDataExtractor.extract(facesContext, uiComponent)
                 .getInformation(PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
 
         if(propertyDetails.getBaseObject() == null)
@@ -118,14 +99,15 @@
             return;
         }
 
-        addMetaDataToContext(propertyInformation, uiComponent);
-
-        Class[] foundGroups = ExtValBeanValidationContext.getCurrentInstance().getGroups(
-                facesContext.getViewRoot().getViewId(),
-                uiComponent.getClientId(facesContext));
+        /*TODO
+            //TODO extract groups - see ValidationGroupProvider
+            Class[] foundGroups = ExtValBeanValidationContext.getCurrentInstance().getGroups(
+                    facesContext.getViewRoot().getViewId(),
+                    uiComponent.getClientId(facesContext));
 
-        foundGroups = mergeFoundGroupsWithValidatorGroups(
+            foundGroups = mergeFoundGroupsWithValidatorGroups(
                 foundGroups, ((EditableValueHolder)uiComponent).getValidators());
+         */
 
         BeanDescriptor beanDescriptor = this.validationFactory.getValidator().getConstraintsForClass(
                 propertyDetails.getBaseObject().getClass()/*, foundGroups*/);
@@ -136,7 +118,7 @@
         {
             return;
         }
-
+        
         ValidationStrategy validationStrategy;
         MetaDataTransformer metaDataTransformer;
         MetaDataEntry entry;
@@ -145,7 +127,7 @@
         for (ConstraintDescriptor<?> constraintDescriptor : elementDescriptor.getConstraintDescriptors())
         {
             //TODO check groups
-
+            
             validationStrategy = new BeanValidationStrategyAdapter(constraintDescriptor);
 
             /*
@@ -196,52 +178,6 @@
         }
     }
 
-    @ToDo(value = Priority.HIGH, description = "check if f:validateBean deactivates validation")
-    private boolean isValidationDisabled(Validator[] validators)
-    {
-        //
-        return false;
-    }
-
-
-    @ToDo.List({@ToDo(value = Priority.HIGH, description = "optimize"),
-            @ToDo(value = Priority.HIGH, description = "use reflection instead of BeanValidator for jsf 1.x versions"),
-            @ToDo(value = Priority.HIGH, description = "test")
-    })
-    private Class[] mergeFoundGroupsWithValidatorGroups(Class[] foundGroups, Validator[] validators)
-    {
-        List<String> validatorsOfTagList = new ArrayList<String>();
-
-        for (Validator validator : validators)
-        {
-            if (validator instanceof BeanValidator)
-            {
-                validatorsOfTagList.addAll(
-                        Arrays.asList(((BeanValidator) validator).getValidationGroups().split(",")));
-            }
-        }
-
-        List<Class> result = new ArrayList<Class>(Arrays.asList(foundGroups));
-        Class currentClass;
-        for(String groupClassName : validatorsOfTagList)
-        {
-            currentClass = ClassUtils.tryToLoadClassForName(groupClassName);
-
-            if(currentClass != null && currentClass.isInterface())
-            {
-                result.add(currentClass);
-            }
-            else
-            {
-                if(this.logger.isErrorEnabled())
-                {
-                    this.logger.error(groupClassName + " is no valid group - only existing interfaces are allowed");
-                }
-            }
-        }
-        return result.toArray(new Class[result.size()]);
-    }
-
     @Override
     public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
             throws ConverterException, SkipBeforeInterceptorsException, SkipRendererDelegationException
@@ -272,7 +208,7 @@
         }
     }
 
-    private boolean processComponent(UIComponent uiComponent)
+    protected boolean processComponent(UIComponent uiComponent)
     {
         return uiComponent instanceof EditableValueHolder;
     }
@@ -280,16 +216,6 @@
     @ToDo(value = Priority.HIGH, description = "use ExtValUtils#createFacesMessage")
     protected void processValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject)
     {
-        if (logger.isTraceEnabled())
-        {
-            logger.trace("jsr303 start validation");
-        }
-
-        if(isValidationDisabled(((EditableValueHolder)uiComponent).getValidators()))
-        {
-            return;
-        }
-
         if (!"true".equalsIgnoreCase(WebXmlParameter.DEACTIVATE_EMPTY_STRING_INTERPRETATION)
                 && "".equals(convertedObject))
         {
@@ -300,129 +226,32 @@
 
         PropertyInformation propertyInformation = metaDataExtractor.extract(facesContext, uiComponent);
 
-        //extract group validation annotations
-        addMetaDataToContext(propertyInformation, uiComponent);
-
-        processFieldValidation(facesContext, uiComponent, convertedObject, propertyInformation);
-
-        if (logger.isTraceEnabled())
-        {
-            logger.trace("jsr303 validation finished");
-        }
-    }
-
-    protected void addMetaDataToContext(PropertyInformation propertyInformation, UIComponent component)
-    {
-        PropertyDetails propertyDetails = propertyInformation
-                .getInformation(PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
-
-        String[] key = propertyDetails.getKey().split("\\.");
-
-        Object firstBean = ExtValUtils.getELHelper().getBean(key[0]);
-
-        List<Class> foundGroupsForPropertyValidation = new ArrayList<Class>();
-        List<Class> restrictedGroupsForPropertyValidation = new ArrayList<Class>();
-        List<ModelValidationEntry> modelValidationEntryList = new ArrayList<ModelValidationEntry>();
-        List<Class> restrictedGroupsForModelValidation = new ArrayList<Class>();
-
-        //extract bv-controller-annotation of
-
-        //first bean
-        processClass(firstBean,
-                foundGroupsForPropertyValidation,
-                restrictedGroupsForPropertyValidation,
-                modelValidationEntryList,
-                restrictedGroupsForModelValidation);
-
-        //first property
-        processFieldsAndProperties(key[0] + "." + key[1],
-                firstBean,
-                key[1],
-                foundGroupsForPropertyValidation,
-                restrictedGroupsForPropertyValidation,
-                modelValidationEntryList,
-                restrictedGroupsForModelValidation);
-
-        //base object (of target property)
-        processClass(propertyDetails.getBaseObject(),
-                foundGroupsForPropertyValidation,
-                restrictedGroupsForPropertyValidation,
-                modelValidationEntryList,
-                restrictedGroupsForModelValidation);
-
-        //last property
-        processFieldsAndProperties(
-                propertyDetails.getKey(),
-                propertyDetails.getBaseObject(),
-                propertyDetails.getProperty(),
-                foundGroupsForPropertyValidation,
-                restrictedGroupsForPropertyValidation,
-                modelValidationEntryList,
-                restrictedGroupsForModelValidation);
-
-        ExtValBeanValidationContext extValBeanValidationContext = ExtValBeanValidationContext.getCurrentInstance();
-        String currentViewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
-
-        String clientId = component.getClientId(FacesContext.getCurrentInstance());
-
-        processFoundGroups(extValBeanValidationContext, currentViewId, clientId,
-                foundGroupsForPropertyValidation);
-
-        processRestrictedGroups(extValBeanValidationContext, currentViewId, clientId,
-                restrictedGroupsForPropertyValidation);
-
-        initModelValidation(extValBeanValidationContext, currentViewId, component, propertyDetails,
-                modelValidationEntryList, restrictedGroupsForModelValidation);
-    }
-
-    protected void processFoundGroups(ExtValBeanValidationContext extValBeanValidationContext,
-                                      String currentViewId,
-                                      String clientId,
-                                      List<Class> foundGroupsForPropertyValidation)
-    {
-        for (Class currentGroupClass : foundGroupsForPropertyValidation)
-        {
-            extValBeanValidationContext.addGroup(currentGroupClass, currentViewId, clientId);
-        }
-    }
-
-    protected void processRestrictedGroups(ExtValBeanValidationContext extValBeanValidationContext,
-                                         String currentViewId,
-                                         String clientId,
-                                         List<Class> restrictedGroupsForPropertyValidation)
-    {
-        for (Class currentGroupClass : restrictedGroupsForPropertyValidation)
+        //e.g.: extract groups for validation
+        if(!ExtValUtils.executeBeforeValidationInterceptors(facesContext, uiComponent, convertedObject,
+                PropertyInformation.class.getName() ,propertyInformation))
         {
-            extValBeanValidationContext.restrictGroup(currentGroupClass, currentViewId, clientId);
+            return;
         }
-    }
 
-    protected void initModelValidation(ExtValBeanValidationContext extValBeanValidationContext,
-                                     String currentViewId,
-                                     UIComponent component,
-                                     PropertyDetails propertyDetails,
-                                     List<ModelValidationEntry> modelValidationEntryList,
-                                     List<Class> restrictedGroupsForModelValidation)
-    {
-        for(ModelValidationEntry modelValidationEntry : modelValidationEntryList)
+        try
         {
-            if(!"true".equalsIgnoreCase(org.apache.myfaces.extensions.validator.beanval.WebXmlParameter
-                    .DEACTIVATE_IMPLICIT_DEFAULT_GROUP_VALIDATION))
+            if (logger.isTraceEnabled())
             {
-                modelValidationEntry.addGroup(Default.class);
+                logger.trace("jsr303 start validation");
             }
 
-            for(Class restrictedGroup : restrictedGroupsForModelValidation)
-            {
-                modelValidationEntry.removeGroup(restrictedGroup);
-            }
+            processFieldValidation(facesContext, uiComponent, convertedObject, propertyInformation);
 
-            if(modelValidationEntry.getGroups().length > 0)
+            if (logger.isTraceEnabled())
             {
-                addTargetsForModelValidation(modelValidationEntry, propertyDetails.getBaseObject());
-                extValBeanValidationContext.addModelValidationEntry(modelValidationEntry, currentViewId, component);
+                logger.trace("jsr303 validation finished");
             }
         }
+        finally
+        {
+            ExtValUtils.executeAfterValidationInterceptors(facesContext, uiComponent, convertedObject,
+                    PropertyInformation.class.getName(), propertyInformation);
+        }
     }
 
     protected void processFieldValidation(FacesContext facesContext,
@@ -441,9 +270,6 @@
         Class[] groups = beanValidationContext.getGroups(
                 facesContext.getViewRoot().getViewId(), uiComponent.getClientId(facesContext));
 
-        groups = mergeFoundGroupsWithValidatorGroups(
-                groups, ((EditableValueHolder)uiComponent).getValidators());
-
         if(groups == null)
         {
             return;
@@ -489,292 +315,4 @@
         }
     }
     
-    private void processClass(Object objectToInspect,
-                              List<Class> foundGroupsForPropertyValidation,
-                              List<Class> restrictedGroupsForPropertyValidation,
-                              List<ModelValidationEntry> modelValidationEntryList,
-                              List<Class> restrictedGroupsForModelValidation)
-    {
-        Class classToInspect = objectToInspect.getClass();
-        while (!Object.class.getName().equals(classToInspect.getName()))
-        {
-            transferGroupValidationInformationToFoundGroups(objectToInspect,
-                    foundGroupsForPropertyValidation,
-                    restrictedGroupsForPropertyValidation,
-                    modelValidationEntryList,
-                    restrictedGroupsForModelValidation);
-
-            processInterfaces(objectToInspect.getClass(), objectToInspect,
-                    foundGroupsForPropertyValidation,
-                    restrictedGroupsForPropertyValidation,
-                    modelValidationEntryList,
-                    restrictedGroupsForModelValidation);
-
-            classToInspect = classToInspect.getSuperclass();
-        }
-    }
-
-    private void processInterfaces(Class currentClass,
-                                   Object metaDataSourceObject,
-                                   List<Class> foundGroupsForPropertyValidation,
-                                   List<Class> restrictedGroupsForPropertyValidation,
-                                   List<ModelValidationEntry> modelValidationEntryList,
-                                   List<Class> restrictedGroupsForModelValidation)
-    {
-        for (Class currentInterface : currentClass.getInterfaces())
-        {
-            transferGroupValidationInformationToFoundGroups(metaDataSourceObject,
-                    foundGroupsForPropertyValidation,
-                    restrictedGroupsForPropertyValidation,
-                    modelValidationEntryList,
-                    restrictedGroupsForModelValidation);
-
-            processInterfaces(currentInterface, metaDataSourceObject,
-                    foundGroupsForPropertyValidation,
-                    restrictedGroupsForPropertyValidation,
-                    modelValidationEntryList,
-                    restrictedGroupsForModelValidation);
-        }
-    }
-
-    private void transferGroupValidationInformationToFoundGroups(Object objectToInspect,
-                                                                 List<Class> foundGroupsForPropertyValidation,
-                                                                 List<Class> restrictedGroupsForPropertyValidation,
-                                                                 List<ModelValidationEntry> modelValidationEntryList,
-                                                                 List<Class> restrictedGroupsForModelValidation)
-    {
-        if (objectToInspect.getClass().isAnnotationPresent(BeanValidation.class))
-        {
-            processMetaData(objectToInspect.getClass().getAnnotation(BeanValidation.class),
-                    objectToInspect,
-                    foundGroupsForPropertyValidation,
-                    restrictedGroupsForPropertyValidation,
-                    modelValidationEntryList,
-                    restrictedGroupsForModelValidation);
-        }
-        else if (objectToInspect.getClass().isAnnotationPresent(BeanValidation.List.class))
-        {
-            for(BeanValidation currentBeanValidation :
-                    (objectToInspect.getClass().getAnnotation(BeanValidation.List.class)).value())
-            {
-                processMetaData(currentBeanValidation,
-                        objectToInspect,
-                        foundGroupsForPropertyValidation,
-                        restrictedGroupsForPropertyValidation,
-                        modelValidationEntryList,
-                        restrictedGroupsForModelValidation);
-            }
-        }
-    }
-
-    private void processFieldsAndProperties(String key,
-                                            Object base,
-                                            String property, List<Class> foundGroupsForPropertyValidation,
-                                            List<Class> restrictedGroupsForPropertyValidation,
-                                            List<ModelValidationEntry> modelValidationEntryList,
-                                            List<Class> restrictedGroupsForModelValidation)
-    {
-        PropertyInformation propertyInformation = new DefaultGroupControllerScanningExtractor()
-                .extract(FacesContext.getCurrentInstance(), new PropertyDetails(key, base, property));
-
-        for (MetaDataEntry metaDataEntry : propertyInformation.getMetaDataEntries())
-        {
-            if (metaDataEntry.getValue() instanceof BeanValidation)
-            {
-                processMetaData((BeanValidation) metaDataEntry.getValue(),
-                        base,
-                        foundGroupsForPropertyValidation,
-                        restrictedGroupsForPropertyValidation,
-                        modelValidationEntryList,
-                        restrictedGroupsForModelValidation);
-            }
-            else if(metaDataEntry.getValue() instanceof BeanValidation.List)
-            {
-                for(BeanValidation currentBeanValidation : ((BeanValidation.List)metaDataEntry.getValue()).value())
-                {
-                    processMetaData(currentBeanValidation,
-                            base,
-                            foundGroupsForPropertyValidation,
-                            restrictedGroupsForPropertyValidation,
-                            modelValidationEntryList,
-                            restrictedGroupsForModelValidation);
-                }
-            }
-        }
-    }
-
-    protected void processMetaData(BeanValidation beanValidation,
-                                 Object metaDataSourceObject,
-                                 List<Class> foundGroupsForPropertyValidation,
-                                 List<Class> restrictedGroupsForPropertyValidation,
-                                 List<ModelValidationEntry> modelValidationEntryList,
-                                 List<Class> restrictedGroupsForModelValidation)
-    {
-        for (String currentViewId : beanValidation.viewIds())
-        {
-            if ((currentViewId.equals(FacesContext.getCurrentInstance().getViewRoot().getViewId()) ||
-                    currentViewId.equals("*")) && isValidationPermitted(beanValidation))
-            {
-                if(isModelValidation(beanValidation))
-                {
-                    addModelValidationEntry(
-                            beanValidation, metaDataSourceObject,
-                            modelValidationEntryList, restrictedGroupsForModelValidation);
-                }
-                else
-                {
-                    processGroups(
-                            beanValidation, foundGroupsForPropertyValidation, restrictedGroupsForPropertyValidation);
-                }
-
-                return;
-            }
-        }
-    }
-
-    private void processGroups(BeanValidation beanValidation,
-                           List<Class> foundGroupsForPropertyValidation,
-                           List<Class> restrictedGroupsForPropertyValidation)
-    {
-        foundGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.useGroups()));
-
-        if(!(beanValidation.restrictGroups().length == 1 &&
-                beanValidation.restrictGroups()[0].equals(NoRestrictionGroup.class)))
-        {
-            restrictedGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.restrictGroups()));
-        }
-    }
-
-    private boolean isModelValidation(BeanValidation beanValidation)
-    {
-        return beanValidation.modelValidation().isActive();
-    }
-
-    private void addModelValidationEntry(BeanValidation beanValidation,
-                                         Object metaDataSourceObject,
-                                         List<ModelValidationEntry> modelValidationEntryList,
-                                         List<Class> restrictedGroupsForModelValidation)
-    {
-        ModelValidationEntry modelValidationEntry = new ModelValidationEntry();
-
-        modelValidationEntry.setGroups(Arrays.asList(beanValidation.useGroups()));
-        modelValidationEntry.setMetaData(beanValidation.modelValidation());
-        modelValidationEntry.setMetaDataSourceObject(metaDataSourceObject);
-
-        if(!(beanValidation.restrictGroups().length == 1 &&
-                beanValidation.restrictGroups()[0].equals(NoRestrictionGroup.class)))
-        {
-            restrictedGroupsForModelValidation.addAll(Arrays.asList(beanValidation.restrictGroups()));
-        }
-
-        modelValidationEntryList.add(modelValidationEntry);
-    }
-
-    private void addTargetsForModelValidation(ModelValidationEntry modelValidationEntry, Object defaultTarget)
-    {
-        if(modelValidationEntry.getMetaData().validationTargets().length == 1 &&
-                modelValidationEntry.getMetaData().validationTargets()[0].equals(ModelValidation.DEFAULT_TARGET))
-        {
-            modelValidationEntry.addValidationTarget(defaultTarget);
-        }
-        else
-        {
-            Object target;
-            for(String modelValidationTarget : modelValidationEntry.getMetaData().validationTargets())
-            {
-                target = resolveTarget(modelValidationEntry.getMetaDataSourceObject(), modelValidationTarget);
-
-                if(target == null && this.logger.isErrorEnabled())
-                {
-                    this.logger.error("target unreachable - source class: " +
-                            modelValidationEntry.getMetaDataSourceObject().getClass().getName() +
-                            " target to resolve: " + modelValidationTarget);
-                }
-
-                modelValidationEntry.addValidationTarget(target);
-            }
-        }
-    }
-
-    private Object resolveTarget(Object metaDataSourceObject, String modelValidationTarget)
-    {
-        ELHelper elHelper = ExtValUtils.getELHelper();
-
-        if(elHelper.isELTermWellFormed(modelValidationTarget))
-        {
-            if(elHelper.isELTermValid(FacesContext.getCurrentInstance(), modelValidationTarget))
-            {
-                return elHelper.getValueOfExpression(
-                        FacesContext.getCurrentInstance(), new ValueBindingExpression(modelValidationTarget));
-            }
-            else
-            {
-                if(this.logger.isErrorEnabled())
-                {
-                    this.logger.error("an invalid binding is used: " + modelValidationTarget);
-                }
-            }
-        }
-
-        String[] properties = modelValidationTarget.split("\\.");
-
-        Object result = metaDataSourceObject;
-        for(String property : properties)
-        {
-            result = getValueOfProperty(result, property);
-
-            if(result == null)
-            {
-                return null;
-            }
-        }
-
-        return result;
-    }
-
-    @ToDo(value = Priority.HIGH, description = "move to util class - the original method is in LocalCompareStrategy")
-    protected 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);
-    }
-
-    private boolean isValidationPermitted(BeanValidation beanValidation)
-    {
-        ELHelper elHelper = ExtValUtils.getELHelper();
-
-        for(String condition : beanValidation.conditions())
-        {
-            if(elHelper.isELTermWellFormed(condition) &&
-                    elHelper.isELTermValid(FacesContext.getCurrentInstance(), condition))
-            {
-                if(Boolean.TRUE.equals(
-                        elHelper.getValueOfExpression(
-                                FacesContext.getCurrentInstance(), new ValueBindingExpression(condition))))
-                {
-                    return true;
-                }
-            }
-            else
-            {
-                if(this.logger.isErrorEnabled())
-                {
-                    this.logger.error("an invalid condition is used: " + condition);
-                }
-            }
-        }
-        return false;
-    }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java?rev=778236&r1=778235&r2=778236&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java Sun May 24 21:12:14 2009
@@ -20,6 +20,8 @@
 
 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 javax.faces.application.ApplicationFactory;
 import javax.faces.application.Application;
@@ -29,6 +31,7 @@
  * @author Gerhard Petracek
  * @since 2.x.3
  */
+@UsageInformation(UsageCategory.INTERNAL)
 public class ExtValApplicationFactory extends ApplicationFactory
 {
     private ApplicationFactory wrapped;
@@ -56,7 +59,7 @@
             @Override
             public void addDefaultValidatorId(String s)
             {
-                if(!"javax.faces.Bean".endsWith(s))
+                if(!"javax.faces.Bean".equals(s))
                 {
                     super.addDefaultValidatorId(s);
                 }

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java?rev=778236&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java Sun May 24 21:12:14 2009
@@ -0,0 +1,119 @@
+/*
+ * 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.beanval.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationInterceptor;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+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.beanval.ExtValBeanValidationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.validator.BeanValidator;
+import javax.faces.validator.Validator;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since 2.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class BeanValidationTagAwareValidationInterceptor implements ValidationInterceptor
+{
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    public boolean beforeValidation(FacesContext facesContext,
+                             UIComponent uiComponent,
+                             Object convertedObject,
+                             Map<String, Object> properties)
+    {
+        if(uiComponent instanceof EditableValueHolder && //"filter" cross-validation calls
+                properties.containsKey(PropertyInformation.class.getName()))
+        {
+            inspectValidators(facesContext.getViewRoot().getViewId(),
+                    (EditableValueHolder)uiComponent,
+                    uiComponent.getClientId(facesContext),
+                    ((EditableValueHolder)uiComponent).getValidators());
+        }
+
+        return true;
+    }
+
+    public void afterValidation(FacesContext facesContext,
+                             UIComponent uiComponent,
+                             Object convertedObject,
+                             Map<String, Object> properties)
+    {
+        //not used
+    }
+
+    @ToDo.List({@ToDo(value = Priority.HIGH, description = "optimize"),
+            @ToDo(value = Priority.HIGH, description = "use reflection instead of BeanValidator for jsf 1.x versions"),
+            @ToDo(value = Priority.HIGH, description = "test")
+    })
+    private void inspectValidators(String viewId,
+                                   EditableValueHolder editableValueHolder,
+                                   String clientId,
+                                   Validator[] validators)
+    {
+        List<String> validatorsOfTagList = new ArrayList<String>();
+
+        for (Validator validator : validators)
+        {
+            //don't check with instanceof
+            if (validator.getClass().getName().equals(BeanValidator.class.getName()))
+            {
+                validatorsOfTagList.addAll(
+                        Arrays.asList(((BeanValidator) validator).getValidationGroups().split(",")));
+
+                //prevent double-validation
+                editableValueHolder.removeValidator(validator);
+                editableValueHolder.addValidator(new BeanValidatorWrapper((BeanValidator)validator));
+            }
+        }
+
+        Class currentClass;
+        for(String groupClassName : validatorsOfTagList)
+        {
+            currentClass = ClassUtils.tryToLoadClassForName(groupClassName);
+
+            if(currentClass != null && currentClass.isInterface())
+            {
+                ExtValBeanValidationContext.getCurrentInstance().addGroup(currentClass, viewId, clientId);
+            }
+            else
+            {
+                if(this.logger.isErrorEnabled())
+                {
+                    this.logger.error(groupClassName + " is no valid group - only existing interfaces are allowed");
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java?rev=778236&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java Sun May 24 21:12:14 2009
@@ -0,0 +1,113 @@
+/*
+ * 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.beanval.interceptor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.validator.BeanValidator;
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+/**
+ * replacement for BeanValidator which gets added due to f:validateBean
+ *
+ * @author Gerhard Petracek
+ * @since 2.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+class BeanValidatorWrapper extends BeanValidator
+{
+    private BeanValidator wrapped;
+
+    BeanValidatorWrapper(BeanValidator wrapped)
+    {
+        this.wrapped = wrapped;
+    }
+
+    public BeanValidator getWrappedBeanValidator()
+    {
+        return this.wrapped;
+    }
+
+    public void setWrapped(BeanValidator wrapped)
+    {
+        this.wrapped = wrapped;
+    }
+
+    public void setValidationGroups(String s)
+    {
+        wrapped.setValidationGroups(s);
+    }
+
+    public String getValidationGroups()
+    {
+        return wrapped.getValidationGroups();
+    }
+
+    public void validate(FacesContext facesContext, UIComponent uiComponent, Object o)
+    {
+        //don't validate - the extval bean-validation adapter will do that
+    }
+
+    /*
+    public Object saveState(FacesContext facesContext)
+    {
+        Object result[] = new Object[1];
+        result[0] = wrapped.getValidationGroups();
+        return result;
+    }
+
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        this.wrapped = new BeanValidator();
+
+        if (state != null)
+        {
+            Object values[] = (Object[]) state;
+            this.wrapped.setValidationGroups((String) values[0]);
+        }
+    }
+    */
+
+    public void markInitialState()
+    {
+        wrapped.markInitialState();
+    }
+
+    public boolean initialStateMarked()
+    {
+        return wrapped.initialStateMarked();
+    }
+
+    public void clearInitialState()
+    {
+        wrapped.clearInitialState();
+    }
+
+    public boolean isTransient()
+    {
+        return wrapped.isTransient();
+    }
+
+    public void setTransient(boolean b)
+    {
+        wrapped.setTransient(b);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java?rev=778236&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java Sun May 24 21:12:14 2009
@@ -0,0 +1,64 @@
+/*
+ * 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.beanval.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.interceptor.AbstractRendererInterceptor;
+import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipBeforeInterceptorsException;
+import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipRendererDelegationException;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.render.Renderer;
+import javax.faces.validator.Validator;
+import java.io.IOException;
+
+/**
+ * separated for easier sync
+ *
+ * @author Gerhard Petracek
+ * @since 2.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class ResetBeanValidationRendererInterceptor extends AbstractRendererInterceptor
+{
+    @Override
+    public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+            throws IOException, SkipBeforeInterceptorsException, SkipRendererDelegationException
+    {
+        if(uiComponent instanceof EditableValueHolder)
+        {
+            switchBackValidators((EditableValueHolder)uiComponent);
+        }
+    }
+
+    private void switchBackValidators(EditableValueHolder editableValueHolder)
+    {
+        for(Validator validator : editableValueHolder.getValidators())
+        {
+            if(validator instanceof BeanValidatorWrapper)
+            {
+                editableValueHolder.addValidator(((BeanValidatorWrapper)validator).getWrappedBeanValidator());
+                editableValueHolder.removeValidator(validator);
+            }
+        }
+    }
+}



Mime
View raw message