You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/06/14 10:50:55 UTC

svn commit: r547177 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java

Author: cagatay
Date: Thu Jun 14 01:50:53 2007
New Revision: 547177

URL: http://svn.apache.org/viewvc?view=rev&rev=547177
Log:
Encode an hidden field flag to be used for skipping client validation

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java?view=diff&rev=547177&r1=547176&r2=547177
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java Thu Jun 14 01:50:53 2007
@@ -22,6 +22,7 @@
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
 
 import org.apache.myfaces.custom.clientvalidation.common.CVUtils;
 import org.apache.myfaces.custom.util.ComponentUtils;
@@ -44,6 +45,10 @@
     }
     
     public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
+    	if(CVUtils.isCVEnabled()) {
+    		encodeBypassCVField(facesContext, component);
+    	}
+    	
     	super.encodeEnd(facesContext, component);
     	
     	if(CVUtils.isCVEnabled()) {
@@ -52,4 +57,16 @@
 			CVUtils.encodeValidationScript(facesContext);
     	}
     }
+
+    //Renders a hidden input field that will act as a flag to bypass client validation or not
+	private void encodeBypassCVField(FacesContext facesContext, UIComponent component) throws IOException{
+		ResponseWriter writer = facesContext.getResponseWriter();
+		
+		writer.startElement("input", component);
+		writer.writeAttribute("type", "hidden", null);
+		writer.writeAttribute("id", CVUtils.BYPASS_CLIENT_VALIDATION_FIELD, null);
+		writer.writeAttribute("name", CVUtils.BYPASS_CLIENT_VALIDATION_FIELD, null);
+		writer.writeAttribute("value", "false", null);				//immediate command components make this value true when they're clicked 
+		writer.endElement("input");
+	}
 }