SPR-8661 Add disabled attribute to HiddenInputTag

This commit is contained in:
Rossen Stoyanchev
2011-11-03 16:29:12 +00:00
parent 78fbceff82
commit bba8bb6ec0
4 changed files with 73 additions and 4 deletions

View File

@@ -35,6 +35,28 @@ import javax.servlet.jsp.JspException;
@SuppressWarnings("serial")
public class HiddenInputTag extends AbstractHtmlElementTag {
/**
* The name of the '<code>disabled</code>' attribute.
*/
public static final String DISABLED_ATTRIBUTE = "disabled";
private String disabled;
/**
* Get the value of the '<code>disabled</code>' attribute.
*/
public String getDisabled() {
return this.disabled;
}
/**
* Set the value of the '<code>disabled</code>' attribute.
* May be a runtime expression.
*/
public void setDisabled(String disabled) {
this.disabled = disabled;
}
/**
* Flags "type" as an illegal dynamic attribute.
*/
@@ -54,10 +76,20 @@ public class HiddenInputTag extends AbstractHtmlElementTag {
tagWriter.startTag("input");
writeDefaultAttributes(tagWriter);
tagWriter.writeAttribute("type", "hidden");
if (isDisabled()) {
tagWriter.writeAttribute(DISABLED_ATTRIBUTE, "disabled");
}
String value = getDisplayString(getBoundValue(), getPropertyEditor());
tagWriter.writeAttribute("value", processFieldValue(getName(), value, "hidden"));
tagWriter.endTag();
return SKIP_BODY;
}
/**
* Is the current HTML tag disabled?
*/
protected boolean isDisabled() throws JspException {
return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
}