myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r937331 - in /myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core: interceptor/ renderkit/ startup/
Date Fri, 23 Apr 2010 15:22:29 GMT
Author: gpetracek
Date: Fri Apr 23 15:22:28 2010
New Revision: 937331

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

Added:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/RendererProxy.java
Modified:
    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/renderkit/ExtValLazyRendererProxy.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java

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=937331&r1=937330&r2=937331&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
Fri Apr 23 15:22:28 2010
@@ -29,6 +29,7 @@ import org.apache.myfaces.extensions.val
 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.core.renderkit.exception.SkipAfterInterceptorsException;
+import org.apache.myfaces.extensions.validator.core.renderkit.RendererProxy;
 import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 
@@ -92,7 +93,14 @@ public abstract class AbstractValidation
 
         try
         {
-            convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+            if(wrapped instanceof RendererProxy)
+            {
+                convertedObject = ((RendererProxy)wrapped).getCachedConvertedValue(facesContext,
uiComponent, o);
+            }
+            else
+            {
+                convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+            }
         }
         catch (PropertyNotFoundException r)
         {

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValLazyRendererProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValLazyRendererProxy.java?rev=937331&r1=937330&r2=937331&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValLazyRendererProxy.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValLazyRendererProxy.java
Fri Apr 23 15:22:28 2010
@@ -38,7 +38,7 @@ import java.util.logging.Logger;
  * @since 1.x.1
  */
 @UsageInformation(UsageCategory.INTERNAL)
-class ExtValLazyRendererProxy extends Renderer
+class ExtValLazyRendererProxy extends Renderer implements RendererProxy
 {
     protected final Logger logger = Logger.getLogger(getClass().getName());
 
@@ -90,6 +90,16 @@ class ExtValLazyRendererProxy extends Re
         return getLazyRenderer().getRendersChildren();
     }
 
+    public Object getCachedConvertedValue(FacesContext facesContext, UIComponent uiComponent,
Object o)
+        throws ConverterException
+    {
+        if(getLazyRenderer() instanceof RendererProxy)
+        {
+            return ((RendererProxy)getLazyRenderer()).getCachedConvertedValue(facesContext,
uiComponent, o);
+        }
+        return getLazyRenderer().getConvertedValue(facesContext, uiComponent, o);
+    }
+
     @Override
     public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object
o)
         throws ConverterException
@@ -131,4 +141,8 @@ class ExtValLazyRendererProxy extends Re
         }
     }
 
+    public Renderer getWrappedRenderer()
+    {
+        return this.wrapped;
+    }
 }
\ No newline at end of file

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java?rev=937331&r1=937330&r2=937331&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
Fri Apr 23 15:22:28 2010
@@ -41,7 +41,7 @@ import java.util.logging.Logger;
  * @since 1.x.1
  */
 @UsageInformation(UsageCategory.INTERNAL)
-public class ExtValRendererProxy extends Renderer
+public class ExtValRendererProxy extends Renderer implements RendererProxy
 {
     public static final String KEY = ExtValRendererProxy.class.getName() + ":KEY";
     protected final Logger logger = Logger.getLogger(getClass().getName());
@@ -200,6 +200,26 @@ public class ExtValRendererProxy extends
         }
     }
 
+    public Object getCachedConvertedValue(FacesContext facesContext, UIComponent uiComponent,
Object o)
+    {
+        RendererProxyStorageEntry entry = getRendererEntry(facesContext, uiComponent);
+
+        if (entry.getConvertedValue() == null)
+        {
+            try
+            {
+                entry.setConvertedValue(wrapped.getConvertedValue(facesContext, uiComponent,
o));
+            }
+            catch (RuntimeException r)
+            {
+                resetComponentProxyMapping();
+                throw r;
+            }
+        }
+
+        return entry.getConvertedValue();
+    }
+
     @Override
     public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object
o)
         throws ConverterException
@@ -277,4 +297,9 @@ public class ExtValRendererProxy extends
 
         logger.fine("turn on the development mode for further information, if something is
displayed wrong.");
     }
+
+    public Renderer getWrappedRenderer()
+    {
+        return this.wrapped;
+    }
 }

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/RendererProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/RendererProxy.java?rev=937331&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/RendererProxy.java
(added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/RendererProxy.java
Fri Apr 23 15:22:28 2010
@@ -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.core.renderkit;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.render.Renderer;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface RendererProxy
+{
+    Renderer getWrappedRenderer();
+
+    Object getCachedConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object
object);
+}

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=937331&r1=937330&r2=937331&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
Fri Apr 23 15:22:28 2010
@@ -65,7 +65,6 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.core.validation.IgnoreConstraintSource;
 import org.apache.myfaces.extensions.validator.core.validation.TargetProperty;
 import org.apache.myfaces.extensions.validator.core.validation.TargetPropertyId;
-import org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererProxy;
 import org.apache.myfaces.extensions.validator.util.ClassUtils;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.util.JsfUtils;
@@ -93,9 +92,6 @@ public class ExtValStartupListener exten
 
         ExtValContext.getContext().registerRendererInterceptor(new ValidationInterceptor());
 
-        ExtValContext.getContext()
-                .addGlobalProperty(ExtValRendererProxy.KEY, ExtValRendererProxy.class.getName(),
false);
-
         initNameMappers();
         initValidationExceptionInterceptors();
         initViolationSeverityInterpreter();



Mime
View raw message