myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r740096 - in /myfaces/extensions/validator/trunk: component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/ validation-modules/property-validation/src/main/java/org/apache/myfaces/extensi...
Date Mon, 02 Feb 2009 20:34:00 GMT
Author: gpetracek
Date: Mon Feb  2 20:34:00 2009
New Revision: 740096

URL: http://svn.apache.org/viewvc?rev=740096&view=rev
Log:
EXTVAL-34 basic CoreOutputLabel support

Modified:
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/PropertyValidationModuleStartupListener.java

Modified: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java?rev=740096&r1=740095&r2=740096&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
Mon Feb  2 20:34:00 2009
@@ -26,9 +26,9 @@
 import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
 import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.CustomInformation;
 import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
-import org.apache.myfaces.extensions.validator.util.ClassUtils;
 import org.apache.myfaces.extensions.validator.trinidad.util.TrinidadUtils;
 import org.apache.myfaces.trinidad.component.core.output.CoreOutputLabel;
 
@@ -38,7 +38,7 @@
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-import java.lang.annotation.Annotation;
+import java.util.List;
 
 /**
  * @author Gerhard Petracek
@@ -46,19 +46,6 @@
  */
 public class TrinidadRendererInterceptor extends AbstractRendererInterceptor
 {
-    private static Class<Annotation> markerAnnotationClass = null;
-
-    static
-    {
-        Class resultingClass = ClassUtils.tryToLoadClassForName(
-            "org.apache.myfaces.extensions.validator.baseval.annotation.SkipValidationSupport");
-
-        if(resultingClass != null && Annotation.class.isAssignableFrom(resultingClass))
-        {
-            markerAnnotationClass = resultingClass;
-        }
-    }
-
     public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer
wrapped)
             throws IOException
     {
@@ -121,7 +108,7 @@
                 }
 
                 if(Boolean.TRUE.equals(skipInitialization) && !metaData.isEmpty()
&&
-                        validationStrategy.getClass().isAnnotationPresent(markerAnnotationClass))
+                        isSkipableValidationStrategy(validationStrategy.getClass()))
                 {
                     metaData.put(CommonMetaDataKeys.SKIP_VALIDATION, true);
                 }
@@ -134,4 +121,35 @@
         }
     }
 
+    private boolean isSkipableValidationStrategy(Class<? extends ValidationStrategy>
validationStrategyClass)
+    {
+        String key = ExtValContext.getContext().getInformationProviderBean()
+                .get(CustomInformation.BASE_PACKAGE) + CommonMetaDataKeys.SKIP_VALIDATION.toUpperCase();
+        List<Class> markerList = (List<Class>)ExtValContext.getContext().getGlobalProperty(key);
+
+        if(markerList == null)
+        {
+            return false;
+        }
+
+        for(Class currentClass : markerList)
+        {
+            if(currentClass.isAnnotation())
+            {
+                if(validationStrategyClass.isAnnotationPresent(currentClass))
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                if(currentClass.isAssignableFrom(validationStrategyClass))
+                {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/PropertyValidationModuleStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/PropertyValidationModuleStartupListener.java?rev=740096&r1=740095&r2=740096&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/PropertyValidationModuleStartupListener.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/PropertyValidationModuleStartupListener.java
Mon Feb  2 20:34:00 2009
@@ -19,8 +19,11 @@
 package org.apache.myfaces.extensions.validator;
 
 import org.apache.myfaces.extensions.validator.baseval.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.baseval.annotation.SkipValidationSupport;
 import org.apache.myfaces.extensions.validator.core.startup.AbstractStartupListener;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.CustomInformation;
+import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
 import org.apache.myfaces.extensions.validator.core.interceptor.ValidationInterceptor;
 import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticResourceBundleConfiguration;
 import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfiguration;
@@ -31,6 +34,9 @@
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.crossval.recorder.CrossValidationUserInputRecorder;
 
+import java.util.List;
+import java.util.ArrayList;
+
 /**
  * @author Gerhard Petracek
  * @since 1.x.1
@@ -85,5 +91,17 @@
 
         ExtValContext.getContext().denyRendererInterceptor(ValidationInterceptor.class);
         ExtValContext.getContext().registerRendererInterceptor(new ValidationInterceptorWithSkipValidationSupport());
+
+        String key = ExtValContext.getContext().getInformationProviderBean()
+                    .get(CustomInformation.BASE_PACKAGE) + CommonMetaDataKeys.SKIP_VALIDATION.toUpperCase();
+        List<Class> markerList = (List<Class>)ExtValContext.getContext().getGlobalProperty(key);
+
+        if(markerList == null)
+        {
+            markerList = new ArrayList<Class>();
+            ExtValContext.getContext().addGlobalProperty(key, markerList);
+        }
+        
+        markerList.add(SkipValidationSupport.class);
     }
 }



Mime
View raw message