Is there a way to have REQUIRED messages for different kinds of composite components?
I'd like to be able to say something like the following in a message bundle
javax.faces.component.UIInput.REQUIRED=Please enter a value for {0}
com.anon.sandbox.jsf.component.NameField.REQUIRED=ENTER A {} OR DIE
com.anon.sandbox.jsf.component.EmailField.REQUIRED=You forgot to enter a {0} address
I could do this by implementing custom validators for each kind of input field, but given that the only behaviour I want to customise is the error message this seems like overkill.
Use the
requiredMessage
attribute to specify them.For the case you didn't knew that, the
#{cc.resourceBundleMap}
refers the composite component specific resource bundle which is identified by a.properties
file with the same filename as the composite component in the same folder.So, imagine that you've a composite component file
foo.xhtml
, then you can specify the localized messages infoo.properties
(and consequentlyfoo_en.properties
,foo_es.properties
, etc) which reside in the very same folder. Those localized messages are then available by the aforementioned#{cc.resourceBundleMap}
.