WW-3033 This change rollsback WW-2351. The id should not be change (it break backward compatibility and it is not a good idea), instead the name of the generated function is the one that should be changed

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@754994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2009-03-16 20:09:51 +00:00
parent 649ce30681
commit 120e5a4667
5 changed files with 12 additions and 12 deletions
@@ -859,7 +859,7 @@ public abstract class UIBean extends Component {
protected String escape(String name) {
// escape any possible values that can make the ID painful to work with in JavaScript
if (name != null) {
return name.replaceAll("[^a-zA-Z0-9_]", "_");
return name.replaceAll("[\\/\\.\\[\\]]", "_");
} else {
return "";
}
@@ -35,7 +35,7 @@ END SNIPPET: supported-validators
-->
<#if ((parameters.validate?default(false) == true) && (parameters.performValidation?default(false) == true))>
<script type="text/javascript">
function validateForm_${parameters.id}() {
function validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}() {
form = document.getElementById("${parameters.id}");
clearErrorMessages(form);
clearErrorLabels(form);
@@ -24,8 +24,8 @@
<script type="text/javascript" src="${base}/struts/xhtml/validation.js"></script>
<script type="text/javascript" src="${base}/struts/utils.js"></script>
<#if parameters.onsubmit??>
${tag.addParameter('onsubmit', "${parameters.onsubmit}; return validateForm_${parameters.id}();")}
${tag.addParameter('onsubmit', "${parameters.onsubmit}; return validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}();")}
<#else>
${tag.addParameter('onsubmit', "return validateForm_${parameters.id}();")}
${tag.addParameter('onsubmit', "return validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}();")}
</#if>
</#if>
@@ -98,8 +98,8 @@ public class UIBeanTest extends StrutsTestCase {
assertEquals(bean.escape("hello[world"), "hello_world");
assertEquals(bean.escape("hello.world"), "hello_world");
assertEquals(bean.escape("hello]world"), "hello_world");
assertEquals(bean.escape("hello!world"), "hello_world");
assertEquals(bean.escape("hello!@#$%^&*()world"), "hello__________world");
assertEquals(bean.escape("hello!world"), "hello!world");
assertEquals(bean.escape("hello!@#$%^&*()world"), "hello!@#$%^&*()world");
}
public void testEscapeId() throws Exception {
@@ -1,11 +1,11 @@
<tr>
<td class="tdLabel"></td>
<td>
<input type="radio" name="myMap['name']" id="myMap__name__"value=""/>
<label for="myMap__name__">N/A</label>
<input type="radio" name="myMap['name']" id="myMap__name__Opt." value="Opt."/>
<label for="myMap__name__Opt.">Opt.</label>
<input type="radio" name="myMap['name']" id="myMap__name__Std." checked="checked" value="Std."/>
<label for="myMap__name__Std.">Std.</label>
<input type="radio" name="myMap['name']" id="myMap_'name'_"value=""/>
<label for="myMap_'name'_">N/A</label>
<input type="radio" name="myMap['name']" id="myMap_'name'_Opt." value="Opt."/>
<label for="myMap_'name'_Opt.">Opt.</label>
<input type="radio" name="myMap['name']" id="myMap_'name'_Std." checked="checked" value="Std."/>
<label for="myMap_'name'_Std.">Std.</label>
</td>
</tr>