Author: nbelaevski
Date: 2007-07-03 12:48:03 -0400 (Tue, 03 Jul 2007)
New Revision: 1445
Modified:
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-408 resolved
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-07-03
13:12:05 UTC (rev 1444)
+++
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-07-03
16:48:03 UTC (rev 1445)
@@ -26,6 +26,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.regex.Matcher;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
@@ -304,8 +305,20 @@
getValidJavascriptName(formName));
script.append("(){").append(functionName).append("();}\n");
// MyFaces 1.1.5 clear form function name
- script.append("function
").append("clearFormHiddenParams_").append(
- formName.replace("-", "$_").replace(':', '_'));
+
+ //equivalent for formName.replace("-", "$_")
+ StringBuffer formNameReplaceBuffer = new StringBuffer(formName.length());
+ int idx = -1;
+ int idxA = 0;
+ while ((idx = formName.indexOf('-', idxA)) != -1) {
+ formNameReplaceBuffer.append(formName.substring(idxA, idx));
+ formNameReplaceBuffer.append("$_");
+ idxA = idx + 1;
+ }
+ formNameReplaceBuffer.append(formName.substring(idxA));
+
+ script.append("function
").append("clearFormHiddenParams_").append(formNameReplaceBuffer.toString().
+ replace(':', '_'));
script.append("(){").append(functionName).append("();}\n");
// Just to be sure we call this clear method on each load.
// Otherwise in the case, that someone submits a form by pressing Enter