Set new error messages

UI Components for JSF
Post Reply
almillo
Posts: 9
Joined: 31 Mar 2011, 19:03
Location: Argentina

31 Mar 2011, 19:31

Hi, I'm new using PrimeFaces!
was trying to find if someone has already answered my question previously, but nothing found.

The question is the next:
I want to edit the error messages that primefaces already have as default. For example, I have this:

Code: Select all

# <h:form>  
#               
#     <p:panel id="panel" header="Register">  
#       
#         <p:focus />  
#           
#         <p:messages />  
#           
#         <h:panelGrid columns="3">  
#             <h:outputLabel for="firstname" value="Firstname: *" />  
#             <p:inputText id="firstname" required="true" label="Firstname"  
#                     value="#{personBean.firstname}" >  
#                 <f:validateLength minimum="2" />  
#             </p:inputText>  
#             <p:message for="firstname" />  
#         </h:panelGrid>  
#           
#         <p:commandButton value="Submit" update="panel"   
#                     actionListener="#{personBean.savePerson}" />  
#     </p:panel>  
#   
# </h:form>
This example is the "Focus" demo that is in http://www.primefaces.org/showcase/ui/focus.jsf

This example show the error message: Firstname: Validation Error: Value is less than allowable minimum of '2'

That I need is change the message "Value is less than allowable minimum of '2'" to another. Also if this error message can be internationalized

Somebody knows how can I do it both?

Thanks in advance and sorry if this is a newbie question
Regards!

ps: If this is a the wrong forum, please accept my apologies and move them to the proper
Last edited by almillo on 04 Apr 2011, 14:05, edited 1 time in total.

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

01 Apr 2011, 15:03

You can use the p:inputText validatorMessage attribute and set the value from a ResourceBundle.

Alternatively, if you use BeansValidation you can annotate you entities and provide a message in the annotation.

almillo
Posts: 9
Joined: 31 Mar 2011, 19:03
Location: Argentina

01 Apr 2011, 17:12

Excelent! thanks a lot

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests