myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r947980 - in /myfaces/extensions/validator/trunk: component-support/generic-support/src/main/java/org/apache/myfaces/extensions/validator/generic/renderkit/ core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ core/src/main/j...
Date Tue, 25 May 2010 09:30:27 GMT
Author: gpetracek
Date: Tue May 25 09:30:26 2010
New Revision: 947980

URL: http://svn.apache.org/viewvc?rev=947980&view=rev
Log:
EXTVAL-75, EXTVAL-80, cleanup

Added:
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIfType.java
Modified:
    myfaces/extensions/validator/trunk/component-support/generic-support/src/main/java/org/apache/myfaces/extensions/validator/generic/renderkit/GenericRenderKitWrapperFactory.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/JsfUtils.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java

Modified: myfaces/extensions/validator/trunk/component-support/generic-support/src/main/java/org/apache/myfaces/extensions/validator/generic/renderkit/GenericRenderKitWrapperFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/generic-support/src/main/java/org/apache/myfaces/extensions/validator/generic/renderkit/GenericRenderKitWrapperFactory.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/generic-support/src/main/java/org/apache/myfaces/extensions/validator/generic/renderkit/GenericRenderKitWrapperFactory.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/generic-support/src/main/java/org/apache/myfaces/extensions/validator/generic/renderkit/GenericRenderKitWrapperFactory.java
Tue May 25 09:30:26 2010
@@ -24,7 +24,7 @@ import org.apache.myfaces.extensions.val
 
 import javax.faces.render.RenderKit;
 import java.util.Map;
-import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author Gerhard Petracek
@@ -34,7 +34,7 @@ import java.util.HashMap;
 public class GenericRenderKitWrapperFactory extends AbstractRenderKitWrapperFactory
 {
     private Map<Class<? extends RenderKit>, RenderKit> renderKitCache =
-            new HashMap<Class<? extends RenderKit>, RenderKit>();
+            new ConcurrentHashMap<Class<? extends RenderKit>, RenderKit>();
 
     protected RenderKit createWrapper(RenderKit renderKit)
     {

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
Tue May 25 09:30:26 2010
@@ -115,7 +115,9 @@ public class DefaultELHelper implements 
             valueBindingExpression = valueBindingExpression.replace(" ", "");
         }
 
-        if (getTypeOfExpression(FacesContext.getCurrentInstance(),
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        if (getTypeOfExpression(facesContext,
             new ValueBindingExpression(valueBindingExpression).getBaseExpression()) == null)
         {
             ValueBindingExpression result = FaceletsTaglibExpressionHelper.
@@ -128,7 +130,7 @@ public class DefaultELHelper implements 
             }
 
             Class entityClass = ExtValUtils.getELHelper()
-                .getTypeOfExpression(FacesContext.getCurrentInstance(), result.getBaseExpression());
+                .getTypeOfExpression(facesContext, result.getBaseExpression());
 
             if(entityClass == null)
             {

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=947980&r1=947979&r2=947980&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
Tue May 25 09:30:26 2010
@@ -932,7 +932,7 @@ public class ExtValUtils
 
         if (interpreter.severityBlocksNavigation(facesContext, uiComponent, facesMessage.getSeverity()))
         {
-            FacesContext.getCurrentInstance().renderResponse();
+            facesContext.renderResponse();
         }
     }
 

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/JsfUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/JsfUtils.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/JsfUtils.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/JsfUtils.java
Tue May 25 09:30:26 2010
@@ -126,10 +126,11 @@ public class JsfUtils
      */
     public static boolean isApplicationInitialized()
     {
-        return FacesContext.getCurrentInstance() != null &&
-                (FacesContext.getCurrentInstance().getClass().getName().startsWith("org.apache.myfaces")
||
-                        FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
!= null &&
-                                !FacesContext.getCurrentInstance().getExternalContext().getRequestMap().isEmpty());
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        return facesContext != null &&
+                (facesContext.getClass().getName().startsWith("org.apache.myfaces") ||
+                        facesContext.getExternalContext().getRequestMap() != null &&
+                                !facesContext.getExternalContext().getRequestMap().isEmpty());
     }
 
     private static FacesInformationStorage getFacesInformationStorage()

Modified: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java
(original)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java
Tue May 25 09:30:26 2010
@@ -19,7 +19,7 @@
 package org.apache.myfaces.extensions.validator.test.propval.crossval;
 
 import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
-import static org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType.*;
+import static org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIfType.*;
 
 public class EmptyIf2TestBean
 {

Modified: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java
(original)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java
Tue May 25 09:30:26 2010
@@ -19,7 +19,7 @@
 package org.apache.myfaces.extensions.validator.test.propval.crossval;
 
 import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
-import static org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType.*;
+import static org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIfType.*;
 
 public class EmptyIf4TestBean
 {

Modified: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
Tue May 25 09:30:26 2010
@@ -476,13 +476,14 @@ class ExtValBeanValidationMetaDataIntern
     {
         ELHelper elHelper = ExtValUtils.getELHelper();
 
+        FacesContext facesContext = FacesContext.getCurrentInstance();
         for (String condition : beanValidation.conditions())
         {
             if (elHelper.isELTermWellFormed(condition) &&
-                    elHelper.isELTermValid(FacesContext.getCurrentInstance(), condition))
+                    elHelper.isELTermValid(facesContext, condition))
             {
                 if (Boolean.TRUE.equals(elHelper.getValueOfExpression(
-                        FacesContext.getCurrentInstance(), new ValueBindingExpression(condition))))
+                        facesContext, new ValueBindingExpression(condition))))
                 {
                     return true;
                 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/metadata/transformer/JoinMetaDataTransformer.java
Tue May 25 09:30:26 2010
@@ -75,18 +75,18 @@ public class JoinMetaDataTransformer imp
         Map<String, Object> results = new HashMap<String, Object>();
 
         PropertyDetails propertyDetails;
+        FacesContext facesContext = FacesContext.getCurrentInstance();
         for (String targetExpression : targetExpressions)
         {
             propertyDetails = ExtValUtils
                 .createPropertyDetailsForNewTarget(metaDataEntry, targetExpression);
 
-            for (MetaDataEntry entry : extractor.extract(FacesContext.getCurrentInstance(),
-                                                            propertyDetails).getMetaDataEntries())
+            for (MetaDataEntry entry : extractor.extract(facesContext, propertyDetails).getMetaDataEntries())
             {
                 validationStrategy = ExtValUtils.getValidationStrategyForMetaData(entry.getKey());
 
                 if(validationStrategy == null ||
-                        PropertyValidationUtils.isValidationSkipped(FacesContext.getCurrentInstance(),
+                        PropertyValidationUtils.isValidationSkipped(facesContext,
                                 validationStrategy, entry))
                 {
                     continue;

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
Tue May 25 09:30:26 2010
@@ -59,12 +59,13 @@ public class CrossValidationPhaseListene
         try
         {
             CrossValidationStorage crossValidationStorage = CrossValidationUtils.getOrInitCrossValidationStorage();
+            FacesContext facesContext = FacesContext.getCurrentInstance();
             for (CrossValidationStorageEntry entry : crossValidationStorage.getCrossValidationStorageEntries())
             {
                 try
                 {
                     if(!ExtValUtils.executeGlobalBeforeValidationInterceptors(
-                            FacesContext.getCurrentInstance(),
+                            facesContext,
                             entry.getComponent(),
                             entry.getConvertedObject(),
                             CrossValidationStorageEntry.class.getName(),
@@ -131,7 +132,7 @@ public class CrossValidationPhaseListene
                 finally
                 {
                     ExtValUtils.executeGlobalAfterValidationInterceptors(
-                            FacesContext.getCurrentInstance(),
+                            facesContext,
                             entry.getComponent(),
                             entry.getConvertedObject(),
                             CrossValidationStorageEntry.class.getName(),

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java
Tue May 25 09:30:26 2010
@@ -45,7 +45,7 @@ public @interface EmptyIf
       * optional section
       */
 
-    RequiredIfType is() default RequiredIfType.not_empty;
+    EmptyIfType is() default EmptyIfType.not_empty;
 
     String validationErrorMsgKey() default "field_not_empty";
 

Added: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIfType.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIfType.java?rev=947980&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIfType.java
(added)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIfType.java
Tue May 25 09:30:26 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.crossval.annotation;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * empty means an empty text-field (= empty string) or checkbox (Boolean.FALSE)
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public enum EmptyIfType
+{
+    empty, not_empty
+}
\ No newline at end of file

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java
Tue May 25 09:30:26 2010
@@ -22,6 +22,8 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 
 /**
+ * empty means an empty text-field (= empty string) or checkbox (Boolean.FALSE)
+ * 
  * @author Gerhard Petracek
  * @since 1.x.1
  */

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java?rev=947980&r1=947979&r2=947980&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java
Tue May 25 09:30:26 2010
@@ -19,7 +19,7 @@
 package org.apache.myfaces.extensions.validator.crossval.strategy;
 
 import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
-import org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType;
+import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIfType;
 
 /**
  * @author Rudy De Busscher
@@ -43,11 +43,11 @@ public class EmptyIfStrategy extends Abs
     {
         boolean violationFound = false;
 
-        if (annotation.is().equals(RequiredIfType.empty))
+        if (annotation.is().equals(EmptyIfType.empty))
         {
             violationFound = (isTargetEmpty(target) || Boolean.FALSE.equals(target)) &&
!isSourceEmpty(source);
         }
-        else if (annotation.is().equals(RequiredIfType.not_empty))
+        else if (annotation.is().equals(EmptyIfType.not_empty))
         {
             violationFound = (!isSourceEmpty(source) && !isTargetEmpty(target) &&
!(target instanceof Boolean)) ||
                     (Boolean.TRUE.equals(target) && !isSourceEmpty(source));



Mime
View raw message