This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSF and the fly likes Customized error messages for validateLength Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Customized error messages for validateLength" Watch "Customized error messages for validateLength" New topic
Author

Customized error messages for validateLength

Rishidharan Somu
Greenhorn

Joined: Sep 23, 2007
Posts: 8

Can I display a customized error message for the <f:validateLength>?

<h:inputText id="nameField" value="#{Test.name}">
<f:validateLength minimum="2" maximum="6"/>
<h:message for="nameField"/>
</h:inputText>

The error message that is displayed is "testForm:nameField: Validation Error: Value is greater than allowable maximum of '6'".

Is there any way I can change the error message being displayed?
[ November 08, 2008: Message edited by: Rishidharan Somu ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Make your own messages.properties file, and register it in your faces-config.xml using the <message-bundle> tag. For the properties files, you'll find the full list of messages keys in the JSF specification, 2.5.2.4 Localized Application Messages.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Customized error messages for validateLength
 
Similar Threads
A formatting question with radio buttons
Validation
Reloading JSF
Weird JSF "h:messages" tag behavior
replacing default validator message at h:messages