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/05/15 12:55:05 UTC
svn commit: r538132 -
/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java
Author: cagatay
Date: Tue May 15 03:55:04 2007
New Revision: 538132
URL: http://svn.apache.org/viewvc?view=rev&rev=538132
Log:
Simplified decoration of onsubmit attribute regarding client side 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=538132&r1=538131&r2=538132
==============================================================================
--- 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 Tue May 15 03:55:04 2007
@@ -24,6 +24,7 @@
import javax.faces.context.FacesContext;
import org.apache.myfaces.custom.clientvalidation.common.CVUtils;
+import org.apache.myfaces.custom.util.ComponentUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlFormRendererBase;
/**
@@ -36,9 +37,9 @@
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
if(CVUtils.isCVEnabled()) {
- if(!isDecorated(facesContext, component))
- decorateOnSubmit(facesContext, component);
+ ComponentUtils.decorateEventAttribute(component, "onsubmit", CLIENT_VALIDATON_SCRIPT);
}
+
super.encodeBegin(facesContext, component);
}
@@ -51,22 +52,4 @@
CVUtils.encodeValidationScript(facesContext);
}
}
-
- private boolean isDecorated(FacesContext facesContext, UIComponent child) {
- String onSubmit= (String) child.getAttributes().get("onsubmit");
-
- if(onSubmit == null || onSubmit.indexOf(CLIENT_VALIDATON_SCRIPT) == -1)
- return false;
- else
- return true;
- }
-
- private void decorateOnSubmit(FacesContext facesContext, UIComponent child) {
- String onSubmitEvent = (String) child.getAttributes().get("onsubmit");
-
- if(onSubmitEvent == null)
- child.getAttributes().put("onsubmit", CLIENT_VALIDATON_SCRIPT);
- else
- child.getAttributes().put("onsubmit", onSubmitEvent + ";" + CLIENT_VALIDATON_SCRIPT);
- }
-}
+}
\ No newline at end of file