2 Replies Latest reply on May 22, 2008 5:33 PM by ig rek

    JSF internalization custumized messages validators

    ig rek Newbie

      Hi I m trying to customize the validation message displayed by the validators I ve created for the input fields., in order to make the display in different languages possible.
      Is that possible???


      public class companyNameValidator implements Validator  {
              String validcompanyName = "[a-zA-Z0-9\\s]+";
          public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
              //companyName validator
              String entredcompanyName = (String)value;
              Pattern p =Pattern.compile(validcompanyName);
              Matcher m = p.matcher(entredcompanyName);
               if (!m.matches())
                FacesMessage message = new FacesMessage();
                throw new ValidatorException(message);


       <h:outputText value="#{messages['CompanyName']}"/>
                      <h:inputText label="company" id="Company" required="true" value="#{customer.companyName}">                   
                          <f:validator validatorId="companyNameValidator"/>
                      <rich:message for="Company">
                            <f:facet name="passedMarker">
                                   <h:graphicImage  value="#{theme.img}passed.gif" />  
                            <f:facet name="errorMarker">
                                  <h:graphicImage  value="#{theme.img}error.gif" />  

      Instead of having a XXXXXXXXXXXXXXX message , i want to put something like #{message.validCompanyError}
      and define the message in message.properties.