So as not to pollute the JIRAs too much with speculation or suggestions
that haven't been thought out, I'd like to have a discussion about the
"required" attribute here on the list.

I propose that we revert the changes made in WW-3908, namely -- turn
"requiredLabel" back into "required."   Then, to support the html5 required
boolean attribute, change "themes/simple/text.ftl" to check <#if
parameters.required?default(false)> required="required" </#if>.

This is a backwards compatible change (from the themes/simple/text.ftl
perspective).  It is also backwards compatible with templates made before
Struts 2.3.12.

It has a side effect that modern browsers will enforce client-side
validation for text fields like this:
<@s.textfield name="whatever" required=true />

I believe this side effect to be universally beneficial, but I could be
wrong about that.

CONS:

* Some folks have already gone and updated their templates to change
"required" to "requiredLabel."   These folks would have to go back and
revert that, unless logic was put in to see if requiredLabel was one of
"true" "false" or other.  :-/   On the other hand, this frees up the
"requiredLabel" attribute to be a String again, and allow per-field
overriding of the default asterisk (*) character.

* (maybe) Some folks may not want clients to enforce "required" in forms.

PROS:

* html5 required attribute, being specific to the way a tag is rendered,
should be handled in themes where rendering logic exists.

* Avoids "required=false" problem in 2.3.15.1, which confusingly does cause
modern browsers to require a field.   For this reason alone, "required"
should not be a dynamic attribute.

* Backwards compatible with pre-2.3.12 templates.

* (subjective) Tag usage feels more natural -- "required" sounds like a
boolean,  "requiredLabel" sounds like a String.

What do you guys think?

-rgm

Reply via email to