ValidationMessages.properties
error.name.invalid= Inavlid name
error.name.invalid.spanish= some spanish text
How to use the Spanish validation message instead of English just for a single page in the application based on a property value?
ValidationMessages.properties
error.name.invalid= Inavlid name
error.name.invalid.spanish= some spanish text
How to use the Spanish validation message instead of English just for a single page in the application based on a property value?
If you really would like to do this, you could create custom validators. For example:
@FacesValidator("yourValidator")
public class YourValidator implements Validator
{
@Override
public void validate(FacesContext context, UIComponent component, Object value)
throws ValidatorException
{
ResourceBundle resourceBundle = ResourceBundle.getBundle("/ValidationMessages");
String key = yourKey + (yourProperty ? "" : ".spanish");
String message = resourceBundle.getString(key);
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message);
throw new ValidatorException(facesMessage);
}
}
See also: