I am using hibernate validators with JSF. How can I set my conversion error mes...">

Display conversion error message with <rich: beanValidator / ">

I am using hibernate validators with JSF. How can I set my conversion error messages? I use them as follows, but this did not work:

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

I can configure custom verification messages in my bean as follows:

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

But what to do with conversion errors?

+3
source share
1 answer

You might want to look in the 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}
+3
source

Source: https://habr.com/ru/post/1711776/


All Articles