You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/11/13 03:48:58 UTC

svn commit: r835712 [13/19] - in /myfaces/extensions/validator/branches/branch_for_jsf_2_0: ./ assembly/ assembly/src/ assembly/src/main/ assembly/src/main/assembly/ assembly/src/main/resources/ component-support/ component-support/generic-support/ com...

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptorInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptorInternals.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptorInternals.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptorInternals.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,237 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationVirtualValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+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.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.ValidationModuleKey;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.validation.ConstraintViolation;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+class BeanValidationInterceptorInternals
+{
+    private Log logger;
+
+    BeanValidationInterceptorInternals(Log logger)
+    {
+        this.logger = logger;
+    }
+
+    PropertyDetails extractPropertyDetails(FacesContext facesContext, UIComponent uiComponent)
+    {
+        PropertyDetails result = getComponentMetaDataExtractor(uiComponent)
+                .extract(facesContext, uiComponent)
+                .getInformation(PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
+
+        if (result.getBaseObject() == null && this.logger.isWarnEnabled())
+        {
+            this.logger.warn("no base object at " + result.getKey() +
+                    " component-id: " + uiComponent.getClientId(facesContext));
+        }
+
+        return result.getBaseObject() != null ? result : null;
+    }
+
+    /*
+     * also invokes meta-data extraction interceptors
+     * (see e.g. ExtValBeanValidationMetaDataExtractionInterceptor)
+     */
+    MetaDataExtractor getComponentMetaDataExtractor(UIComponent uiComponent)
+    {
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(ValidationModuleKey.class.getName(), BeanValidationModuleKey.class);
+        properties.put(UIComponent.class.getName(), uiComponent);
+
+        return ExtValUtils.getComponentMetaDataExtractorWith(properties);
+    }
+
+    void initComponentWithPropertyDetails(
+            FacesContext facesContext, UIComponent uiComponent, PropertyDetails propertyDetails)
+    {
+        Class[] foundGroups = resolveGroups(facesContext, uiComponent);
+
+        if (foundGroups == null)
+        {
+            return;
+        }
+        else if(foundGroups.length == 0)
+        {
+            foundGroups = new Class[]{Default.class};
+        }
+
+        ElementDescriptor elementDescriptor = getDescriptorFor(
+                propertyDetails.getBaseObject().getClass(), propertyDetails.getProperty());
+
+        if (elementDescriptor == null)
+        {
+            return;
+        }
+
+        Map<String, Object> metaData;
+
+        for (ConstraintDescriptor<?> constraintDescriptor :
+                elementDescriptor.findConstraints().unorderedAndMatchingGroups(foundGroups).getConstraintDescriptors())
+        {
+            metaData = transformConstraintDescriptorToMetaData(
+                    constraintDescriptor, elementDescriptor.getElementClass());
+
+            if (metaData != null && !metaData.isEmpty())
+            {
+                ExtValUtils.configureComponentWithMetaData(facesContext, uiComponent, metaData);
+            }
+        }
+    }
+
+    @ToDo(value = Priority.MEDIUM, description = "ConstraintDescriptor#isReportAsSingleViolation")
+    private Map<String, Object> transformConstraintDescriptorToMetaData(
+            ConstraintDescriptor<?> constraintDescriptor, Class elementClass)
+    {
+        Map<String, Object> result = new HashMap<String, Object>();
+        MetaDataTransformer metaDataTransformer;
+
+        metaDataTransformer = ExtValUtils.getMetaDataTransformerForValidationStrategy(
+                new BeanValidationVirtualValidationStrategy(constraintDescriptor, elementClass));
+
+        if (metaDataTransformer != null)
+        {
+            result.putAll(transformMetaData(metaDataTransformer, constraintDescriptor));
+        }
+
+        if(!constraintDescriptor.isReportAsSingleViolation())
+        {
+            Set<ConstraintDescriptor<?>> composingConstraints = constraintDescriptor.getComposingConstraints();
+            if(composingConstraints != null && !composingConstraints.isEmpty())
+            {
+                result.putAll(transformComposingConstraints(composingConstraints, elementClass));
+            }
+        }
+
+        return result;
+    }
+
+    private Map<String, Object> transformComposingConstraints(
+            Set<ConstraintDescriptor<?>> composingConstraints, Class elementClass)
+    {
+        Map<String, Object> result = new HashMap<String, Object>();
+        for(ConstraintDescriptor constraintDescriptor : composingConstraints)
+        {
+            result.putAll(transformConstraintDescriptorToMetaData(constraintDescriptor, elementClass));
+        }
+
+        return result;
+    }
+
+    private Map<String, Object> transformMetaData(
+            MetaDataTransformer metaDataTransformer, ConstraintDescriptor<?> constraintDescriptor)
+    {
+        MetaDataEntry entry;
+        Map<String, Object> result;
+        if (this.logger.isDebugEnabled())
+        {
+            this.logger.debug(metaDataTransformer.getClass().getName() + " instantiated");
+        }
+
+        entry = new MetaDataEntry();
+        entry.setKey(constraintDescriptor.getAnnotation().annotationType().getName());
+        entry.setValue(constraintDescriptor);
+
+        result = metaDataTransformer.convertMetaData(entry);
+        return result;
+    }
+
+    boolean hasBeanValidationConstraints(PropertyInformation propertyInformation)
+    {
+        PropertyDetails propertyDetails = ExtValUtils.getPropertyDetails(propertyInformation);
+
+        return getDescriptorFor(propertyDetails.getBaseObject().getClass(), propertyDetails.getProperty()) != null;
+    }
+
+    @SuppressWarnings({"unchecked"})
+    Set<ConstraintViolation> validate(FacesContext facesContext,
+                  UIComponent uiComponent,
+                  Object convertedObject,
+                  PropertyInformation propertyInformation)
+    {
+        Class baseBeanClass = getBaseClassType(propertyInformation);
+        String propertyName = getPropertyToValidate(propertyInformation);
+
+        Class[] groups = resolveGroups(facesContext, uiComponent);
+
+        if (groups == null)
+        {
+            return null;
+        }
+
+        return ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory()
+                .usingContext()
+                .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
+                .getValidator()
+                .validateValue(baseBeanClass, propertyName, convertedObject, groups);
+    }
+
+    private Class getBaseClassType(PropertyInformation propertyInformation)
+    {
+        return ExtValUtils.getPropertyDetails(propertyInformation).getBaseObject().getClass();
+    }
+
+    private String getPropertyToValidate(PropertyInformation propertyInformation)
+    {
+        return ExtValUtils.getPropertyDetails(propertyInformation).getProperty();
+    }
+
+    private Class[] resolveGroups(FacesContext facesContext, UIComponent uiComponent)
+    {
+        return ExtValBeanValidationContext.getCurrentInstance().getGroups(
+                facesContext.getViewRoot().getViewId(),
+                uiComponent.getClientId(facesContext));
+    }
+
+    private ElementDescriptor getDescriptorFor(Class targetClass, String property)
+    {
+        BeanDescriptor beanDescriptor = ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory()
+                .getValidator().getConstraintsForClass(targetClass);
+
+        return beanDescriptor.getConstraintsForProperty(property);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleKey.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleKey.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleKey.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleKey.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.ValidationModuleKey;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@ValidationModuleKey
+@UsageInformation(UsageCategory.API)
+public interface BeanValidationModuleKey
+{
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,175 @@
+/*
+ * 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;
+
+import org.apache.myfaces.extensions.validator.beanval.validation.message.interpolator.DefaultMessageInterpolator;
+import org.apache.myfaces.extensions.validator.beanval.validation.message.interpolator.ExtValMessageInterpolatorAdapter;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationVirtualValidationStrategy;
+import org.apache.myfaces.extensions.validator.beanval.storage.ModelValidationEntry;
+import org.apache.myfaces.extensions.validator.beanval.storage.ModelValidationStorage;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+import org.apache.myfaces.extensions.validator.beanval.annotation.ModelValidation;
+import org.apache.myfaces.extensions.validator.core.validation.message.resolver.MessageResolver;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.storage.GroupStorage;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.validation.MessageInterpolator;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import java.util.Map;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+public class ExtValBeanValidationContext implements GroupStorage, ModelValidationStorage
+{
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    private static final String KEY = ExtValBeanValidationContext.class.getName() + ":KEY";
+
+    private MessageInterpolator defaultMessageInterpolator;
+
+    private MessageResolver messageResolver;
+
+    private GroupStorage groupStorage;
+
+    private ModelValidationStorage modelValidationStorage;
+
+    private ExtValBeanValidationContext()
+    {
+        initGroupStorage();
+        initModelValidationStorage();
+
+        initMessageResolver();
+        initMessageInterpolator();
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public static ExtValBeanValidationContext getCurrentInstance()
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        Map requestMap = facesContext.getExternalContext().getRequestMap();
+
+        ExtValBeanValidationContext currentContext = (ExtValBeanValidationContext)requestMap.get(KEY);
+
+        if(currentContext == null)
+        {
+            currentContext = new ExtValBeanValidationContext();
+            requestMap.put(KEY, currentContext);
+        }
+
+        return currentContext;
+    }
+
+    public ValidatorFactory getValidatorFactory()
+    {
+        Object validatorFactory = ExtValContext.getContext().getGlobalProperty(ValidatorFactory.class.getName());
+
+        if(validatorFactory instanceof ValidatorFactory)
+        {
+            return (ValidatorFactory)validatorFactory;
+        }
+
+        if(this.logger.isWarnEnabled())
+        {
+            this.logger.warn("fallback to the default bv validator factory");
+        }
+        return Validation.buildDefaultValidatorFactory();
+    }
+
+    public MessageInterpolator getMessageInterpolator()
+    {
+        if(this.messageResolver != null)
+        {
+            return new ExtValMessageInterpolatorAdapter(this.defaultMessageInterpolator, this.messageResolver);
+        }
+
+        return this.defaultMessageInterpolator;
+    }
+
+    public void addGroup(Class groupClass, String viewId, String clientId)
+    {
+        this.groupStorage.addGroup(groupClass, viewId, clientId);
+    }
+
+    public void restrictGroup(Class groupClass, String viewId, String clientId)
+    {
+        this.groupStorage.restrictGroup(groupClass, viewId, clientId);
+    }
+
+    public Class[] getGroups(String viewId, String clientId)
+    {
+        return this.groupStorage.getGroups(viewId, clientId);
+    }
+
+    public void addModelValidationEntry(ModelValidationEntry modelValidationEntry)
+    {
+        this.modelValidationStorage.addModelValidationEntry(modelValidationEntry);
+    }
+
+    public List<ModelValidationEntry> getModelValidationEntriesToValidate()
+    {
+        return this.modelValidationStorage.getModelValidationEntriesToValidate();
+    }
+
+    private void initGroupStorage()
+    {
+        this.groupStorage = ExtValUtils
+                .getStorage(GroupStorage.class, BeanValidation.class.getName());
+    }
+
+    private void initModelValidationStorage()
+    {
+        this.modelValidationStorage = ExtValUtils.
+                getStorage(ModelValidationStorage.class, ModelValidation.class.getName());
+    }
+
+    private void initMessageInterpolator()
+    {
+        Object foundBean = ExtValUtils.getELHelper().getBean(MessageInterpolator.class.getName().replace(".", "_"));
+
+        if(foundBean instanceof MessageInterpolator)
+        {
+            this.defaultMessageInterpolator = (MessageInterpolator)foundBean;
+        }
+        else
+        {
+            this.defaultMessageInterpolator = new DefaultMessageInterpolator(
+                Validation.buildDefaultValidatorFactory().getMessageInterpolator());
+        }
+    }
+
+    private void initMessageResolver()
+    {
+        this.messageResolver = ExtValUtils.getMessageResolverForValidationStrategy(getBeanValidationStrategy());
+    }
+
+    private ValidationStrategy getBeanValidationStrategy()
+    {
+        return new BeanValidationVirtualValidationStrategy(null, null);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/HtmlCoreComponentsComponentInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/HtmlCoreComponentsComponentInitializer.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/HtmlCoreComponentsComponentInitializer.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/HtmlCoreComponentsComponentInitializer.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import org.apache.myfaces.extensions.validator.core.initializer.component
+        .AbstractHtmlCoreComponentsComponentInitializer;
+import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+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.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(200)
+@UsageInformation(UsageCategory.INTERNAL)
+public class HtmlCoreComponentsComponentInitializer extends AbstractHtmlCoreComponentsComponentInitializer
+{
+    protected void configureRequiredAttribute(FacesContext facesContext,
+                                              UIComponent uiComponent,
+                                              Map<String, Object> metaData)
+    {
+        if(!ExtValUtils.interpretEmptyStringValuesAsNull())
+        {
+            return;
+        }
+
+        if(Boolean.TRUE.equals(metaData.get(CommonMetaDataKeys.REQUIRED)) ||
+                Boolean.TRUE.equals(isComponentRequired(uiComponent)))
+        {
+            ((EditableValueHolder)uiComponent).setRequired(true);
+        }
+        else
+        {
+            ((EditableValueHolder)uiComponent).setRequired(false);
+        }
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.annotation;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.validation.groups.Default;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+
+@Target({METHOD, FIELD, TYPE})
+@Retention(RUNTIME)
+@UsageInformation(UsageCategory.API)
+@Documented
+public @interface BeanValidation
+{
+    String[] viewIds() default "*";
+
+    Class[] useGroups() default Default.class;
+
+    Class[] restrictGroups() default {};
+
+    String[] conditions() default "#{true}";
+
+    ModelValidation modelValidation() default @ModelValidation;
+    
+    @Retention(RUNTIME) static @interface List
+    {
+        BeanValidation[] value();
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.annotation;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+
+@Target({METHOD, FIELD, TYPE})
+@Retention(RUNTIME)
+@UsageInformation(UsageCategory.API)
+@Documented
+public @interface ModelValidation
+{
+    public static final String DEFAULT_TARGET = "base";
+    public static final String DEFAULT_MESSAGE = "org.apache.myfaces.extensions.validator.bv_message";
+
+    boolean isActive() default false;
+
+    boolean displayInline() default false;
+
+    @ToDo(value = Priority.MEDIUM, description = "support property chain syntax")
+    String[] validationTargets() default DEFAULT_TARGET;
+
+    String message() default DEFAULT_MESSAGE;
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.annotation.extractor;
+
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.DefaultPropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+public class DefaultGroupControllerScanningExtractor extends DefaultComponentMetaDataExtractor
+{
+    @Override
+    public PropertyInformation extract(FacesContext facesContext, Object object)
+    {
+        if (!(object instanceof PropertyDetails))
+        {
+            throw new IllegalStateException(object.getClass() + " is not a " + PropertyDetails.class.getName());
+        }
+
+        PropertyDetails propertyDetails = (PropertyDetails)object;
+
+        Class entityClass = propertyDetails.getBaseObject().getClass();
+
+        PropertyInformation propertyInformation = new DefaultPropertyInformation();
+        propertyInformation.setInformation(PropertyInformationKeys.PROPERTY_DETAILS, propertyDetails);
+
+        findAndAddAnnotations(propertyInformation, propertyDetails, entityClass);
+
+        return propertyInformation;
+    }
+
+    private void findAndAddAnnotations(PropertyInformation propertyInformation,
+                                       PropertyDetails propertyDetails,
+                                       Class entityClass)
+    {
+        addPropertyAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
+        addFieldAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.factory;
+
+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;
+import javax.faces.application.ApplicationWrapper;
+
+/**
+ * @author Gerhard Petracek
+ * @since 2.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class ExtValApplicationFactory extends ApplicationFactory
+{
+    private ApplicationFactory wrapped;
+
+    public ExtValApplicationFactory(ApplicationFactory wrapped)
+    {
+        this.wrapped = wrapped;
+    }
+
+    public ApplicationFactory getWrapped()
+    {
+        return wrapped.getWrapped();
+    }
+
+    @ToDo(value = Priority.HIGH, description = "context param. to deactivate this wrapper")
+    public Application getApplication()
+    {
+        return new ApplicationWrapper() {
+
+            public Application getWrapped()
+            {
+                return wrapped.getApplication();
+            }
+
+            @Override
+            public void addDefaultValidatorId(String s)
+            {
+                if(!"javax.faces.Bean".equals(s))
+                {
+                    super.addDefaultValidatorId(s);
+                }
+            }
+        };
+    }
+
+    public void setApplication(Application application)
+    {
+        wrapped.setApplication(application);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationExceptionInterceptor.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationExceptionInterceptor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationExceptionInterceptor.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,66 @@
+/*
+ * 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 org.apache.myfaces.extensions.validator.core.interceptor.ValidationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.validator.ValidatorException;
+import javax.faces.context.FacesContext;
+
+/**
+ * extracts and adds the extval bv meta-data (e.g. validation groups) to the ExtValBeanValidationContext
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(200)
+@UsageInformation(UsageCategory.INTERNAL)
+public class BeanValidationExceptionInterceptor implements ValidationExceptionInterceptor
+{
+
+    public boolean afterThrowing(UIComponent uiComponent,
+                                 MetaDataEntry metaDataEntry,
+                                 Object convertedObject,
+                                 ValidatorException validatorException,
+                                 ValidationStrategy validatorExceptionSource)
+    {
+        if(uiComponent instanceof EditableValueHolder && isBlockingException(uiComponent, validatorException))
+        {
+            //bv integration doesn't throw exceptions to support multiple messages -> set component state
+            ((EditableValueHolder)uiComponent).setValid(false);
+        }
+        return true;
+    }
+
+    private boolean isBlockingException(UIComponent uiComponent, ValidatorException validatorException)
+    {
+        return ExtValContext.getContext().getViolationSeverityInterpreter().severityCausesValidatorException(
+                FacesContext.getCurrentInstance(),
+                uiComponent,
+                validatorException.getFacesMessage().getSeverity());
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidationTagAwareValidationInterceptor.java Fri Nov 13 02:48:45 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.PropertyValidationInterceptor;
+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 PropertyValidationInterceptor
+{
+    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_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/BeanValidatorWrapper.java Fri Nov 13 02:48:45 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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ExtValBeanValidationMetaDataExtractionInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ExtValBeanValidationMetaDataExtractionInterceptor.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ExtValBeanValidationMetaDataExtractionInterceptor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ExtValBeanValidationMetaDataExtractionInterceptor.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,86 @@
+/*
+ * 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 org.apache.myfaces.extensions.validator.core.interceptor.MetaDataExtractionInterceptor;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.ValidationModuleAware;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.beanval.BeanValidationModuleKey;
+import org.apache.myfaces.extensions.validator.beanval.util.BeanValidationUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.util.JsfUtils;
+
+import javax.faces.component.UIComponent;
+import java.util.Map;
+
+/**
+ * extracts and adds the extval bv meta-data (e.g. validation groups) to the ExtValBeanValidationContext
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(200)
+@UsageInformation(UsageCategory.INTERNAL)
+public class ExtValBeanValidationMetaDataExtractionInterceptor
+        implements MetaDataExtractionInterceptor, ValidationModuleAware
+{
+    public void afterExtracting(PropertyInformation propertyInformation)
+    {
+        if(propertyInformation.containsInformation(PropertyInformationKeys.CUSTOM_PROPERTIES))
+        {
+            Map properties = propertyInformation.getInformation(PropertyInformationKeys.CUSTOM_PROPERTIES, Map.class);
+
+            if(properties != null && properties.containsKey(UIComponent.class.getName()))
+            {
+                UIComponent uiComponent = (UIComponent)properties.get(UIComponent.class.getName());
+                PropertyDetails propertyDetails = ExtValUtils.getPropertyDetails(propertyInformation);
+
+                processExtValBeanValidationMetaData(uiComponent, propertyDetails);
+            }
+        }
+    }
+
+    /**
+     * adds the extval bv meta-data to the ExtValBeanValidationContext
+     *
+     * @param uiComponent current component
+     * @param propertyDetails property details of the value-binding
+     */
+    private void processExtValBeanValidationMetaData(UIComponent uiComponent, PropertyDetails propertyDetails)
+    {
+        if(JsfUtils.isRenderResponsePhase())
+        {
+            BeanValidationUtils.addMetaDataToContext(uiComponent, propertyDetails, false);
+        }
+        else
+        {
+            BeanValidationUtils.addMetaDataToContext(uiComponent, propertyDetails, true);
+        }
+    }
+
+    public String[] getModuleKeys()
+    {
+        return new String[] {BeanValidationModuleKey.class.getName()};
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/ResetBeanValidationRendererInterceptor.java Fri Nov 13 02:48:45 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);
+            }
+        }
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/AbstractBeanValidationMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/AbstractBeanValidationMetaDataTransformer.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/AbstractBeanValidationMetaDataTransformer.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/AbstractBeanValidationMetaDataTransformer.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,90 @@
+/*
+ * 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.metadata.transformer;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+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.beanval.payload.DisableClientSideValidation;
+import org.apache.myfaces.extensions.validator.beanval.payload.ViolationSeverity;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.Payload;
+import javax.faces.application.FacesMessage;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.annotation.Annotation;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation({UsageCategory.REUSE})
+public abstract class AbstractBeanValidationMetaDataTransformer<T extends Annotation> implements MetaDataTransformer
+{
+    @SuppressWarnings({"unchecked"})
+    public Map<String, Object> convertMetaData(MetaDataEntry metaDataEntry)
+    {
+        ConstraintDescriptor<? extends T> constraintDescriptor = metaDataEntry.getValue(ConstraintDescriptor.class);
+
+        if(isClientSideValidationEnabled(constraintDescriptor) && isBlockingConstraint(constraintDescriptor))
+        {
+            return transformMetaData((ConstraintDescriptor<T>)constraintDescriptor);
+        }
+        return new HashMap<String, Object>();
+    }
+
+    protected boolean isClientSideValidationEnabled(ConstraintDescriptor<? extends T> constraintDescriptor)
+    {
+        for(Class<? extends Payload> payload : constraintDescriptor.getPayload())
+        {
+            if(DisableClientSideValidation.class.isAssignableFrom(payload))
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    protected boolean isBlockingConstraint(ConstraintDescriptor<?> constraintDescriptor)
+    {
+        FacesMessage testMessage = new FacesMessage();
+        testMessage.setSeverity(ViolationSeverity.Error.VALUE);
+
+        for (Class<? extends Payload> payload : constraintDescriptor.getPayload())
+        {
+            if (ViolationSeverity.Warn.class.isAssignableFrom(payload))
+            {
+                testMessage.setSeverity(ViolationSeverity.Warn.VALUE);
+            }
+            else if(ViolationSeverity.Info.class.isAssignableFrom(payload))
+            {
+                testMessage.setSeverity(ViolationSeverity.Info.VALUE);
+            }
+            else if(ViolationSeverity.Fatal.class.isAssignableFrom(payload))
+            {
+                testMessage.setSeverity(ViolationSeverity.Fatal.VALUE);
+            }
+        }
+        return ExtValUtils.severityBlocksSubmitForComponentId(null, testMessage);
+    }
+    protected abstract Map<String, Object> transformMetaData(ConstraintDescriptor<T> constraintDescriptor);
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/NotNullMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/NotNullMetaDataTransformer.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/NotNullMetaDataTransformer.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/NotNullMetaDataTransformer.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.metadata.transformer;
+
+import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.metadata.ConstraintDescriptor;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+public class NotNullMetaDataTransformer extends AbstractBeanValidationMetaDataTransformer<NotNull>
+{
+    protected Map<String, Object> transformMetaData(ConstraintDescriptor<NotNull> constraintDescriptor)
+    {
+        Map<String, Object> results = new HashMap<String, Object>();
+
+        if(ExtValUtils.interpretEmptyStringValuesAsNull())
+        {
+            results.put(CommonMetaDataKeys.WEAK_REQUIRED, true);
+        }
+        return results;
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/StringSizeMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/StringSizeMetaDataTransformer.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/StringSizeMetaDataTransformer.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/StringSizeMetaDataTransformer.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.metadata.transformer;
+
+import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
+
+import javax.validation.constraints.Size;
+import javax.validation.metadata.ConstraintDescriptor;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+public class StringSizeMetaDataTransformer extends AbstractBeanValidationMetaDataTransformer<Size>
+{
+    protected Map<String, Object> transformMetaData(ConstraintDescriptor<Size> constraintDescriptor)
+    {
+        Map<String, Object> results = new HashMap<String, Object>();
+        Size annotation = constraintDescriptor.getAnnotation();
+
+        int minimum = annotation.min();
+
+        if(minimum != 0)
+        {
+            results.put(CommonMetaDataKeys.MIN_LENGTH, minimum);
+            results.put(CommonMetaDataKeys.WEAK_REQUIRED, true);
+        }
+        else
+        {
+            results.put(CommonMetaDataKeys.MIN_LENGTH_DEFAULT, minimum);
+        }
+
+        int maximum = annotation.max();
+        if(maximum != Integer.MAX_VALUE)
+        {
+            results.put(CommonMetaDataKeys.MAX_LENGTH, maximum);
+        }
+        else
+        {
+            results.put(CommonMetaDataKeys.MAX_LENGTH_DEFAULT, maximum);
+        }
+
+        return results;
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,55 @@
+/*
+ * 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.metadata.transformer.mapper;
+
+import org.apache.myfaces.extensions.validator.core.metadata.transformer.mapper
+        .AbstractValidationStrategyToMetaDataTransformerNameMapper;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationVirtualValidationStrategy;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation({UsageCategory.REUSE})
+public abstract class AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper
+    extends AbstractValidationStrategyToMetaDataTransformerNameMapper
+{
+    public final String createName(ValidationStrategy source)
+    {
+        if(isBeanValidationStrategy(source))
+        {
+            BeanValidationVirtualValidationStrategy beanValidationAdapter =
+                    (BeanValidationVirtualValidationStrategy)source;
+
+            return createBeanValidationTransformerName(beanValidationAdapter);
+        }
+        return null;
+    }
+
+    private boolean isBeanValidationStrategy(ValidationStrategy source)
+    {
+        return source instanceof BeanValidationVirtualValidationStrategy;
+    }
+
+    protected  abstract String createBeanValidationTransformerName(
+            BeanValidationVirtualValidationStrategy validationStrategy);
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/NotNullNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/NotNullNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/NotNullNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/NotNullNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.metadata.transformer.mapper;
+
+import org.apache.myfaces.extensions.validator.beanval.metadata.transformer.NotNullMetaDataTransformer;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationVirtualValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.Nested;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@Nested
+@InvocationOrder(200)
+@UsageInformation({UsageCategory.INTERNAL})
+public class NotNullNameMapper extends AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper
+{
+    protected String createBeanValidationTransformerName(BeanValidationVirtualValidationStrategy adapter)
+    {
+        if(isNotNullConstraint(adapter))
+        {
+            return NotNullMetaDataTransformer.class.getName();
+        }
+        return null;
+    }
+
+    private boolean isNotNullConstraint(BeanValidationVirtualValidationStrategy adapter)
+    {
+        return NotNull.class.getName().equals(
+                adapter.getConstraintDescriptor().getAnnotation().annotationType().getName());
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/SizeNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/SizeNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/SizeNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/SizeNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,54 @@
+/*
+ * 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.metadata.transformer.mapper;
+
+import org.apache.myfaces.extensions.validator.core.Nested;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationVirtualValidationStrategy;
+import org.apache.myfaces.extensions.validator.beanval.metadata.transformer.StringSizeMetaDataTransformer;
+
+import javax.validation.constraints.Size;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@Nested
+@InvocationOrder(210)
+@UsageInformation({UsageCategory.INTERNAL})
+public class SizeNameMapper extends AbstractBeanValidationVirtualValidationStrategyToMetaDataTransformerNameMapper
+{
+    protected String createBeanValidationTransformerName(BeanValidationVirtualValidationStrategy adapter)
+    {
+        if(isStringSizeConstraint(adapter))
+        {
+            return StringSizeMetaDataTransformer.class.getName();
+        }
+        return null;
+    }
+
+    private boolean isStringSizeConstraint(BeanValidationVirtualValidationStrategy adapter)
+    {
+        return Size.class.getName().equals(
+                adapter.getConstraintDescriptor().getAnnotation().annotationType().getName()) &&
+                String.class.getName().equals(adapter.getElementClass().getName());
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/DisableClientSideValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/DisableClientSideValidation.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/DisableClientSideValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/DisableClientSideValidation.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,33 @@
+/*
+ * 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.payload;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.validation.Payload;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface DisableClientSideValidation extends Payload
+{
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/ViolationSeverity.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/ViolationSeverity.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/ViolationSeverity.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/payload/ViolationSeverity.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.payload;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.validation.Payload;
+import javax.faces.application.FacesMessage;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface ViolationSeverity
+{
+    interface Info extends Payload
+    {
+        FacesMessage.Severity VALUE = FacesMessage.SEVERITY_INFO;
+    }
+
+    interface Warn extends Payload
+    {
+        FacesMessage.Severity VALUE = FacesMessage.SEVERITY_WARN;
+    }
+
+    interface Error extends Payload
+    {
+        FacesMessage.Severity VALUE = FacesMessage.SEVERITY_ERROR;
+    }
+
+    interface Fatal extends Payload
+    {
+        FacesMessage.Severity VALUE = FacesMessage.SEVERITY_FATAL;
+    }
+}