Board index JavaServer Faces General Set new error messages

Set new error messages

Components, Ajax Framework, Utilities and More.

Post 31 Mar 2011, 19:31

Posts: 9
Location: Argentina
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:

# <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.

Post 01 Apr 2011, 15:03

Posts: 723
Location: United States
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.

Post 01 Apr 2011, 17:12

Posts: 9
Location: Argentina
Excelent! thanks a lot


Return to General