Browse Source

Add newline at the beginning of textarea macro for FreeMarker and Velocity

Issue: SPR-13503
pull/1014/merge
Kazuki Shimizu 9 years ago committed by Brian Clozel
parent
commit
9b2023111d
  1. 3
      spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl
  2. 3
      spring-webmvc/src/main/resources/org/springframework/web/servlet/view/velocity/spring.vm
  3. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java
  4. 9
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityMacroTests.java

3
spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl

@ -202,7 +202,8 @@ @@ -202,7 +202,8 @@
-->
<#macro formTextarea path attributes="">
<@bind path/>
<textarea id="${status.expression?replace('[','')?replace(']','')}" name="${status.expression}" ${attributes}>${stringStatusValue}</textarea>
<textarea id="${status.expression?replace('[','')?replace(']','')}" name="${status.expression}" ${attributes}>
${stringStatusValue}</textarea>
</#macro>
<#--

3
spring-webmvc/src/main/resources/org/springframework/web/servlet/view/velocity/spring.vm

@ -161,7 +161,8 @@ @@ -161,7 +161,8 @@
*#
#macro( springFormTextarea $path $attributes )
#springBind($path)
<textarea id="#springXmlId(${status.expression})" name="${status.expression}" ${attributes}>$!status.value</textarea>
<textarea id="#springXmlId(${status.expression})" name="${status.expression}" ${attributes}>
$!status.value</textarea>
#end
#**

4
spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java

@ -211,12 +211,12 @@ public class FreeMarkerMacroTests { @@ -211,12 +211,12 @@ public class FreeMarkerMacroTests {
@Test
public void testForm3() throws Exception {
assertEquals("<textarea id=\"name\" name=\"name\" >Darren</textarea>", getMacroOutput("FORM3"));
assertEquals("<textarea id=\"name\" name=\"name\" >\nDarren</textarea>", getMacroOutput("FORM3"));
}
@Test
public void testForm4() throws Exception {
assertEquals("<textarea id=\"name\" name=\"name\" rows=10 cols=30>Darren</textarea>", getMacroOutput("FORM4"));
assertEquals("<textarea id=\"name\" name=\"name\" rows=10 cols=30>\nDarren</textarea>", getMacroOutput("FORM4"));
}
// TODO verify remaining output (fix whitespace)

9
spring-webmvc/src/test/java/org/springframework/web/servlet/view/velocity/VelocityMacroTests.java

@ -184,8 +184,10 @@ public class VelocityMacroTests { @@ -184,8 +184,10 @@ public class VelocityMacroTests {
if (tokens[i].equals("URL")) assertEquals("/springtest/aftercontext.html", tokens[i + 1]);
if (tokens[i].equals("FORM1")) assertEquals("<input type=\"text\" id=\"name\" name=\"name\" value=\"Darren\" >", tokens[i + 1]);
if (tokens[i].equals("FORM2")) assertEquals("<input type=\"text\" id=\"name\" name=\"name\" value=\"Darren\" class=\"myCssClass\">", tokens[i + 1]);
if (tokens[i].equals("FORM3")) assertEquals("<textarea id=\"name\" name=\"name\" >Darren</textarea>", tokens[i + 1]);
if (tokens[i].equals("FORM4")) assertEquals("<textarea id=\"name\" name=\"name\" rows=10 cols=30>Darren</textarea>", tokens[i + 1]);
if (tokens[i].equals("FORM3")) assertEquals("<textarea id=\"name\" name=\"name\" >", tokens[i + 1]);
if (tokens[i].equals("FORM3")) assertEquals("Darren</textarea>", tokens[i + 2]);
if (tokens[i].equals("FORM4")) assertEquals("<textarea id=\"name\" name=\"name\" rows=10 cols=30>", tokens[i + 1]);
if (tokens[i].equals("FORM4")) assertEquals("Darren</textarea>", tokens[i + 2]);
//TODO verify remaining output (fix whitespace)
if (tokens[i].equals("FORM9")) assertEquals("<input type=\"password\" id=\"name\" name=\"name\" value=\"\" >", tokens[i + 1]);
if (tokens[i].equals("FORM10")) assertEquals("<input type=\"hidden\" id=\"name\" name=\"name\" value=\"Darren\" >", tokens[i + 1]);
@ -248,7 +250,8 @@ public class VelocityMacroTests { @@ -248,7 +250,8 @@ public class VelocityMacroTests {
for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equals("FORM1")) assertEquals("<input type=\"text\" id=\"spouses0.name\" name=\"spouses[0].name\" value=\"Fred\" >", tokens[i + 1]); //
if (tokens[i].equals("FORM2")) assertEquals("<textarea id=\"spouses0.name\" name=\"spouses[0].name\" >Fred</textarea>", tokens[i + 1]);
if (tokens[i].equals("FORM2")) assertEquals("<textarea id=\"spouses0.name\" name=\"spouses[0].name\" >", tokens[i + 1]);
if (tokens[i].equals("FORM2")) assertEquals("Fred</textarea>", tokens[i + 2]);
if (tokens[i].equals("FORM3")) assertEquals("<select id=\"spouses0.name\" name=\"spouses[0].name\" >", tokens[i + 1]);
if (tokens[i].equals("FORM4")) assertEquals("<select multiple=\"multiple\" id=\"spouses\" name=\"spouses\" >", tokens[i + 1]);
if (tokens[i].equals("FORM5")) assertEquals("<input type=\"radio\" name=\"spouses[0].name\" value=\"Darren\"", tokens[i + 1]);

Loading…
Cancel
Save