myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r906470 - in /myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator: core/initializer/component/ core/interceptor/ core/startup/ util/
Date Thu, 04 Feb 2010 12:43:12 GMT
Author: gpetracek
Date: Thu Feb  4 12:43:07 2010
New Revision: 906470

URL: http://svn.apache.org/viewvc?rev=906470&view=rev
Log:
EXTVAL-79

Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java?rev=906470&r1=906469&r2=906470&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
Thu Feb  4 12:43:07 2010
@@ -25,7 +25,6 @@
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
 import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
-import org.apache.myfaces.extensions.validator.core.ExtValContext;
 
 import javax.faces.context.FacesContext;
 import javax.faces.component.UIComponent;
@@ -52,7 +51,7 @@
     {
         if(processComponent(uiComponent))
         {
-            if(validateEmptyFields() && isRequiredInitializationActive())
+            if(validateEmptyFields() && ExtValUtils.isRequiredInitializationActive())
             {
                 configureRequiredAttribute(facesContext, uiComponent, metaData);
             }
@@ -66,11 +65,6 @@
         return ExtValUtils.validateEmptyFields();
     }
 
-    private boolean isRequiredInitializationActive()
-    {
-        return Boolean.TRUE.equals(ExtValContext.getContext().getGlobalProperty("init:required"));
-    }
-
     protected abstract void configureRequiredAttribute(FacesContext facesContext,
                                               UIComponent uiComponent,
                                               Map<String, Object> metaData);

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java?rev=906470&r1=906469&r2=906470&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
Thu Feb  4 12:43:07 2010
@@ -64,18 +64,13 @@
          * the required flag in a component leads to problems with h:messages (additional
message) as well as
          * incompatibilities with skip validation and severities
          */
-        if(uiComponent instanceof EditableValueHolder &&
-                isRequiredInitializationSupported() && isRequiredInitializationActive())
+        if(uiComponent instanceof EditableValueHolder && ExtValUtils.isRequiredResetActivated()
&&
+                isRequiredInitializationSupported() && ExtValUtils.isRequiredInitializationActive())
         {
             ((EditableValueHolder)uiComponent).setRequired(false);
         }
     }
 
-    private boolean isRequiredInitializationActive()
-    {
-        return Boolean.TRUE.equals(ExtValContext.getContext().getGlobalProperty("init:required"));
-    }
-
     @Override
     public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer
wrapped)
             throws IOException, SkipBeforeInterceptorsException, SkipRendererDelegationException

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java?rev=906470&r1=906469&r2=906470&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
Thu Feb  4 12:43:07 2010
@@ -234,7 +234,21 @@
         {
             boolean requiredInitialization = "true".equalsIgnoreCase(WebXmlParameter.ACTIVATE_REQUIRED_INITIALIZATION);
 
-            ExtValContext.getContext().addGlobalProperty("init:required", requiredInitialization);
+            ExtValContext.getContext().addGlobalProperty("mode:init:required", requiredInitialization,
false);
+
+            if(requiredInitialization)
+            {
+                deactivateRequiredAttributeSupport();
+            }
         }
     }
+
+    /**
+     * if it's configured that required init should happen,
+     * it's required to deactivate the support for the required attribute
+     */
+    private void deactivateRequiredAttributeSupport()
+    {
+        ExtValContext.getContext().addGlobalProperty("mode:reset:required", Boolean.TRUE,
false);
+    }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java?rev=906470&r1=906469&r2=906470&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
Thu Feb  4 12:43:07 2010
@@ -921,4 +921,24 @@
         }
         return targetComponent;
     }
+
+    /**
+     * @return true if component initialization for required validation is activated
+     */
+    public static boolean isRequiredInitializationActive()
+    {
+        return Boolean.TRUE.equals(ExtValContext.getContext().getGlobalProperty("mode:init:required"));
+    }
+
+    /**
+     * needed for some component libs - if required initialization is used e.g. for visual
indicators
+     * but features like severity aware validation aren't used.
+     * in such a case it's possible to use the required attribute.
+     * 
+     * @return false to deactivate the final reset of the value of the required attribute
+     */
+    public static boolean isRequiredResetActivated()
+    {
+        return Boolean.TRUE.equals(ExtValContext.getContext().getGlobalProperty("mode:reset:required"));
+    }
 }



Mime
View raw message