WW-3828 adds support for dynamic attributes not only for String literals but for other objects

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1343701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2012-05-29 12:43:59 +00:00
parent 8bd9cc6f48
commit b70bdeefda
3 changed files with 9 additions and 3 deletions
@@ -24,7 +24,11 @@
<#assign aKeys = parameters.dynamicAttributes.keySet()><#rt/>
<#list aKeys as aKey><#rt/>
<#assign keyValue = parameters.dynamicAttributes[aKey]/>
<#assign value = struts.translateVariables(keyValue)!keyValue/>
<#if keyValue?is_string>
<#assign value = struts.translateVariables(keyValue)!keyValue/>
<#else>
<#assign value = keyValue?string/>
</#if>
${aKey}="${value?html}"<#rt/>
</#list><#rt/>
</#if><#rt/>
@@ -216,7 +216,8 @@ public class FreeMarkerResultTest extends StrutsTestCase {
ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(request, dispatcher.getConfigurationManager());
dispatcher.serviceAction(request, response, servletContext, mapping);
String expected = "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" placeholder=\"input\" foo=\"bar\"/>"
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" placeholder=\"input\" foo=\"bar\"/>";
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" placeholder=\"input\" foo=\"bar\"/>"
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" break=\"true\"/>";
assertEquals(expected, stringWriter.toString());
}
@@ -21,4 +21,5 @@
*/
-->
<@s.textfield name="test" dynamicAttributes={"placeholder":"input","foo":"bar"}/>
<@s.textfield name="test" placeholder="input" foo="bar"/>
<@s.textfield name="test" placeholder="input" foo="bar"/>
<@s.textfield name="test" break=true />