mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-01 11:49:04 +00:00
Ensure consistent ButtonTag value attribute processing
Closes gh-37017
This commit is contained in:
+3
-1
@@ -67,6 +67,7 @@ import org.springframework.web.servlet.support.RequestDataValueProcessor;
|
||||
* </table>
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -152,7 +153,8 @@ public class ButtonTag extends AbstractHtmlElementTag {
|
||||
*/
|
||||
protected void writeValue(TagWriter tagWriter) throws JspException {
|
||||
String valueToUse = (getValue() != null ? getValue() : getDefaultValue());
|
||||
tagWriter.writeAttribute("value", processFieldValue(getName(), valueToUse, getType()));
|
||||
tagWriter.writeAttribute("value",
|
||||
processFieldValue(getName(), getDisplayString(valueToUse), getType()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+15
@@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
class ButtonTagTests extends AbstractFormTagTests {
|
||||
|
||||
@@ -58,6 +59,20 @@ class ButtonTagTests extends AbstractFormTagTests {
|
||||
assertAttributeNotPresent(output, "disabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
void value() throws Exception {
|
||||
this.tag.setValue("\"My Button\"");
|
||||
|
||||
assertThat(this.tag.doStartTag()).isEqualTo(Tag.EVAL_BODY_INCLUDE);
|
||||
assertThat(this.tag.doEndTag()).isEqualTo(Tag.EVAL_PAGE);
|
||||
|
||||
String output = getOutput();
|
||||
assertTagOpened(output);
|
||||
assertTagClosed(output);
|
||||
|
||||
assertContainsAttribute(output, "value", ""My Button"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void disabled() throws Exception {
|
||||
this.tag.setDisabled(true);
|
||||
|
||||
Reference in New Issue
Block a user