How to use I18N with a custom validator?

This is my custom validator:

publicvoid validate(FacesContext context, UIComponent component, Object value)throws ValidatorException

{

Pattern pat=Pattern.compile(".+@.+\\.[a-z]+");

Matcher m= pat.matcher(value.toString());

if(!m.find())

{

FacesMessage message =new FacesMessage("Not a valid e-mail address");

thrownew ValidatorException(message);

}

}

Instead of providing the text "Not a valid e-mai address", I'd like to get the text out of my ApplicationResources property file.

How can I do this?

I know how to use it with the provided validators, but not with own custom ones

Please help me out, thanks

[1088 byte] By [Mohorovicica] at [2007-11-27 2:36:58]
# 1

I found a solution for this problem, I don't know it's best practice but here it is :

public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException

{

String errortext;

Pattern pat=Pattern.compile(".+@.+\\.[a-z]+");

Matcher m= pat.matcher(value.toString());

if(!m.find())

{

ResourceBundle bundle =

ResourceBundle.getBundle("be.vdab.resources.ApplicationResources", context.getViewRoot().getLocale());

errortext = bundle.getString("erroremail");

FacesMessage message = new FacesMessage(errortext);

throw new ValidatorException(message);

}

}

Mohorovicica at 2007-7-12 2:56:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...