mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Fixed parsing of name for ognl when no id is specified and using name value
WW-1617 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@498091 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -872,9 +872,10 @@ public abstract class UIBean extends Component {
|
||||
addParameter("id", id);
|
||||
}
|
||||
} else if (form != null) {
|
||||
addParameter("id", form.getParameters().get("id") + "_" + escape(name));
|
||||
addParameter("id", form.getParameters().get("id") + "_"
|
||||
+ escape(name != null ? findString(name) : null));
|
||||
} else {
|
||||
addParameter("id", escape(name));
|
||||
addParameter("id", escape(name != null ? findString(name) : null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,22 @@ public class UIBeanTest extends StrutsTestCase {
|
||||
|
||||
assertEquals("txtFldId", txtFld.getParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testPopulateComponentHtmlIdWithOgnl() throws Exception {
|
||||
ValueStack stack = ValueStackFactory.getFactory().createValueStack();
|
||||
MockHttpServletRequest req = new MockHttpServletRequest();
|
||||
MockHttpServletResponse res = new MockHttpServletResponse();
|
||||
|
||||
Form form = new Form(stack, req, res);
|
||||
form.getParameters().put("id", "formId");
|
||||
|
||||
TextField txtFld = new TextField(stack, req, res);
|
||||
txtFld.setName("txtFldName%{'1'}");
|
||||
|
||||
txtFld.populateComponentHtmlId(form);
|
||||
|
||||
assertEquals("formId_txtFldName1", txtFld.getParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testPopulateComponentHtmlId2() throws Exception {
|
||||
ValueStack stack = ValueStackFactory.getFactory().createValueStack();
|
||||
|
||||
Reference in New Issue
Block a user