myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r906466 - in /myfaces/extensions/validator/trunk: component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/ component-support/trinidad-support/src/main/java/org/apache/myfaces/e...
Date Thu, 04 Feb 2010 12:39:45 GMT
Author: gpetracek
Date: Thu Feb  4 12:39:37 2010
New Revision: 906466

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

Modified:
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/RequiredInitializer.java
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java

Modified: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/RequiredInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/RequiredInitializer.java?rev=906466&r1=906465&r2=906466&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/RequiredInitializer.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/RequiredInitializer.java
Thu Feb  4 12:39:37 2010
@@ -19,7 +19,6 @@
 package org.apache.myfaces.extensions.validator.trinidad.initializer.component;
 
 import org.apache.myfaces.extensions.validator.core.metadata.CommonMetaDataKeys;
-import org.apache.myfaces.extensions.validator.core.ExtValContext;
 import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
@@ -43,7 +42,7 @@
     public boolean configureTrinidadComponent(FacesContext facesContext, UIComponent uiComponent,
                                               Map<String, Object> metaData)
     {
-        if(!validateEmptyFields() && isRequiredInitializationActive())
+        if(!validateEmptyFields() && ExtValUtils.isRequiredInitializationActive())
         {
             return false;
         }
@@ -73,7 +72,7 @@
             else if(Boolean.TRUE.equals(metaData.get(CommonMetaDataKeys.SKIP_VALIDATION))
&&
                    !Boolean.TRUE.equals(metaData.get(CommonMetaDataKeys.REQUIRED)))
             {
-                if(uiComponent instanceof EditableValueHolder)
+                if(uiComponent instanceof EditableValueHolder && ExtValUtils.isRequiredResetActivated())
                 {
                     ((EditableValueHolder)uiComponent).setRequired(false);
                 }
@@ -87,11 +86,6 @@
         return false;
     }
 
-    private boolean isRequiredInitializationActive()
-    {
-        return Boolean.TRUE.equals(ExtValContext.getContext().getGlobalProperty("init:required"));
-    }
-
     protected boolean validateEmptyFields()
     {
         return ExtValUtils.validateEmptyFields();

Modified: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java?rev=906466&r1=906465&r2=906466&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
Thu Feb  4 12:39:37 2010
@@ -147,11 +147,14 @@
                 !deactivateTrinidadValidationExceptionInterceptor.equalsIgnoreCase("true");
     }
 
-    private void initRequiredInitialization()
+    protected void initRequiredInitialization()
     {
         if(!isRequiredInitializationDeactivated())
         {
-            ExtValContext.getContext().addGlobalProperty("init:required", Boolean.TRUE, false);
+            ExtValContext.getContext().addGlobalProperty("mode:init:required", Boolean.TRUE,
true);
+
+            //there is no support for client-side severity aware validation -> don't reset
the value
+            ExtValContext.getContext().addGlobalProperty("mode:reset:required", Boolean.FALSE,
false);
         }
     }
 

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java?rev=906466&r1=906465&r2=906466&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java
Thu Feb  4 12:39:37 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/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java?rev=906466&r1=906465&r2=906466&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractValidationInterceptor.java
Thu Feb  4 12:39:37 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/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java?rev=906466&r1=906465&r2=906466&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
Thu Feb  4 12:39:37 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/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java?rev=906466&r1=906465&r2=906466&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
Thu Feb  4 12:39:37 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