myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r698820 - in /myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core: ExtValRendererWrapper.java ExtValValidationInterceptor.java RendererProxy.java
Date Thu, 25 Sep 2008 05:05:16 GMT
Author: gpetracek
Date: Wed Sep 24 22:05:16 2008
New Revision: 698820

URL: http://svn.apache.org/viewvc?rev=698820&view=rev
Log:
renderer proxy to avoid multiple calls of renderer methods (by renderer interceptors), cross-component
validation re-activated

Added:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/RendererProxy.java
Modified:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValRendererWrapper.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationInterceptor.java

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValRendererWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValRendererWrapper.java?rev=698820&r1=698819&r2=698820&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValRendererWrapper.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValRendererWrapper.java
Wed Sep 24 22:05:16 2008
@@ -48,7 +48,7 @@
 
     public ExtValRendererWrapper(Renderer wrapped)
     {
-        this.wrapped = wrapped;
+        this.wrapped = new RendererProxy(wrapped);
     }
 
     @Override

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationInterceptor.java?rev=698820&r1=698819&r2=698820&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationInterceptor.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationInterceptor.java
Wed Sep 24 22:05:16 2008
@@ -28,6 +28,7 @@
 import org.apache.myfaces.extensions.validator.util.ValidationUtils;
 import org.apache.myfaces.extensions.validator.util.ClassUtils;
 import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 
 import javax.faces.context.FacesContext;
 import javax.faces.component.UIComponent;
@@ -109,6 +110,7 @@
         }
 
         Object convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+        ExtValUtils.createValueBindingConvertedValueMapping(uiComponent, convertedObject);
         ValidationUtils.processExtValValidation(facesContext, uiComponent, convertedObject);
     }
 

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/RendererProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/RendererProxy.java?rev=698820&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/RendererProxy.java
(added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/RendererProxy.java
Wed Sep 24 22:05:16 2008
@@ -0,0 +1,116 @@
+/*
+ * 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;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+import javax.faces.component.UIComponent;
+import javax.faces.convert.ConverterException;
+import java.io.IOException;
+
+/**
+ * to avoid multiple class within renderer interceptors (e.g. for encode, decode,...
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+class RendererProxy extends Renderer
+{
+    private Renderer wrapped;
+
+    private boolean isDecodeCalled = false;
+    private boolean isEncodeBeginCalled = false;
+    private boolean isEncodeChildrenCalled = false;
+    private boolean isEncodeEndCalled = false;
+
+    private Object convertedValue = null;
+    private String clientId = null;
+    private Boolean rendersChildren;
+
+    public RendererProxy(Renderer renderer)
+    {
+        this.wrapped = renderer;
+    }
+
+    public void decode(FacesContext facesContext, UIComponent uiComponent)
+    {
+        if(!isDecodeCalled)
+        {
+            wrapped.decode(facesContext, uiComponent);
+        }
+    }
+
+    public void encodeBegin(FacesContext facesContext, UIComponent uiComponent)
+        throws IOException
+    {
+        if(!isEncodeBeginCalled)
+        {
+            wrapped.encodeBegin(facesContext, uiComponent);
+        }
+    }
+
+    public void encodeChildren(FacesContext facesContext, UIComponent uiComponent)
+        throws IOException
+    {
+        if(!isEncodeChildrenCalled)
+        {
+            wrapped.encodeChildren(facesContext, uiComponent);
+        }
+    }
+
+    public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
+        throws IOException
+    {
+        if(!isEncodeEndCalled)
+        {
+            wrapped.encodeEnd(facesContext, uiComponent);
+        }
+    }
+
+    public String convertClientId(FacesContext facesContext, String s)
+    {
+        if(this.clientId == null)
+        {
+            this.clientId = wrapped.convertClientId(facesContext, s);
+        }
+        return this.clientId;
+    }
+
+    public boolean getRendersChildren()
+    {
+        if(rendersChildren == null)
+        {
+            this.rendersChildren = wrapped.getRendersChildren();
+        }
+        return rendersChildren;
+    }
+
+    public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object
o)
+        throws ConverterException
+    {
+        if(this.convertedValue == null)
+        {
+            this.convertedValue = wrapped.getConvertedValue(facesContext, uiComponent, o);
+        }
+        return this.convertedValue;
+    }
+}
\ No newline at end of file



Mime
View raw message