What is the purpose of the label attribute in a JSF Command button?
Very well spotted. It has really no meaningful purpose on a <h:commandButton>
.
This attribute is supposed to be present in UIInput
components such as <h:inputText>
only. It's then exactly that value which will then be used in the first message format placeholder {0}
of validation/conversion messages so that it shows up like so with e.g. label="Username"
:
Username: Value is required
If the label
attribute is omitted, it would default to the component's client ID which is often less friendly readable towards the enduser with autogenerated IDs and :
separator and so on like so
formId:inputId: Value is required
This attribute was introduced in JSF 1.2. I think that the mistake of the JSF developer/implementer was to specify the new attrubute for JSF components which generate HTML <input>
, <select>
and <textarea>
elements, not specifically on JSF compnents which extend from UIInput
. This attribute is namely (correctly) absent on <h:commandLink>
which belongs to the same UICommand
family as <h:commandButton>
.
I've reported it as issue 2365.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With