Use requiredMessage attribute
<h:inputSomething required="true" requiredMessage="Foo is required" />
Or use the label attribute and specify the template for the desired message.
<h:inputSomething label="Foo" required="true" />
with CustomMessages.properties in the classpath that contains the custom message template
javax.faces.component.UIInput.REQUIRED = {0} is required.
{0} will be replaced by the value of the label attribute. You can find an overview of all the keys in the JSF specification (for example, the JSF 2.0 spec - chapter 2.5.2.4). Declare the message properties file in faces-config.xml as message-bundle :
<application> <message-bundle>com.example.CustomMessages</message-bundle> </application>
(assuming it's in the com.example package, you can name it whatever you want)
For additional message template templates, check the JSF specification.
Balusc
source share