views:

729

answers:

1

I'm using hibernate validators with JSF. How can i set my conversation error messages. I'am trying such way, but it didn't work:

                        <h:inputText id="input" value="#{myBean.number}" converterMessage="#{msgs.convertError}">
                            <f:convertNumber />
                            <rich:beanValidator />
                            <rich:ajaxValidator event="onblur"/>
                        </h:inputText>

Custom validator messages i can set in my bean:

@NotNull
@Min(value = 1, message="{greateThanOne}")
public long getNumber() {
    return number;
}

But waht to do with conversation error ?

+1  A: 

You may want to look into Faces resource file (jsf-api.jar, javax/faces/Messages.properties). Just define the following keys in your own resource file and configure it in faces-config.xml.

javax.faces.converter.NumberConverter.NUMBER={2}: ''{0}'' is not a number. javax.faces.converter.NumberConverter.NUMBER_detail={2}: ''{0}'' is not a number. Example: {1}