If you're like me, you almost always have your forms setup like this:
<h:outputLabel for="pvalue" value="Value"/>
<h:inputText value="#{propertyAction.propValue}" id="pvalue"/>
Now if there's a validation on this input, you need to mark the label (otherwise users get a really bizarre error message that they won't understand)
<h:outputLabel for="pvalue" value="Value"/>
<h:inputText value="#{propertyAction.propValue}" id="pvalue" label="Value"/>
And if you're using a bundle, it'll look something like this:
<h:outputLabel for="pvalue" value="${msgs['value']}"/>
<h:inputText value="#{propertyAction.propValue}" id="pvalue" label="${msgs['value']}"/>
So why can't JSF be smart enough to realize "Ok, I have an outputLabel for this input type, it has a validation error, let me use that label instead." and make the label attribute optional and can override the outputLabel in this case.
You forgot the
ReplyDelete<h:message for="pvalue" /> :P
Makes it even better. Should be easy enough to do a composite component to do this though. I'll have to give it a try.
It'll be the JSF equivalent of the tuple, implemented a thousand times over in many different projects, because it was left out of the base platform...!