I want to add the attributes disabled
, required
, and autofocus
to Java Spring Forms 3.1. Thanks to some questions I found out how, but I can't get it to work for boolean attributes.
We have a form utility lib that wraps Spring Form so that we can add labels and other things.
Desired JSP:
<formUtil:formInputBox ... autofocus="true" />
Desired output HTML:
<label>...<input type="text" ... autofocus /></label>
This works in our formUtil as JSP:include but doesn't use Spring:
<input type="text" ... <c:if test="${param.autofocus=='true'}">autofocus</c:if> />
This doesn't work in our formUtil Tag but uses Spring:
<form:input ... <c:if test="${autofocus==true}">autofocus</c:if> />
// Gives exception: `Unterminated <form:input tag`.
Question: How do I get the desired output with the desired input? I'd like to keep databinding etc in Spring so I don't want to role my own form fields.
Note:
Boolean attributes in HTML5 don't support boolean values so I can't have autofocus=true
. It has to be just autofocus
or autofocus="autofocus"
.