From 913cc079af07fbb58ea09e73d3fb538714b6a1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?/usr/local/=CE=95=CE=A8=CE=97=CE=95=CE=9B=CE=A9=CE=9D?= Date: Tue, 3 Nov 2015 12:30:34 +0100 Subject: [PATCH] TagWriter can write empty attribute See gh-910 --- .../web/servlet/tags/form/TagWriter.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java index 87cedb5402..29b62c2b93 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java @@ -97,6 +97,19 @@ public class TagWriter { this.writer.append(" ").append(attributeName).append("=\"") .append(attributeValue).append("\""); } + + /** + * Write an empty HTML attribute with the specified name. + *

Be sure to write all attributes before writing + * any inner text or nested tags. + * @throws IllegalStateException if the opening tag is closed + */ + public void writeAttribute(String attributeName) throws JspException { + if (currentState().isBlockTag()) { + throw new IllegalStateException("Cannot write attributes after opening tag is closed."); + } + this.writer.append(" ").append(attributeName); + } /** * Write an HTML attribute if the supplied value is not {@code null}