tags:

views:

889

answers:

1

I have such code:

<h:inputText id="input" value="#{bean.input}">
                           <f:convertNumber />
                           <rich:ajaxValidator event="onblur" />
</h:inputText>

I want that if validation was successful data from "input" was stored in my backing bean. And all this must be on "onblur" event.

And I'm using Hibernate Validator in my backing bean:

@Min(value = 1)
@NotNull(message="{number.not_null}")
public long getInput() {
    return input;
}
A: 

You're using the wrong approach then.

From the Richfaces docs : AjaxValidator "Skips all JSF processing except validation."

You should use <a4j:support> instead

eg.

<h:inputText id="input" value="#{bean.input}">
  <f:convertNumber />
  <a4j:support event="onblur" ajaxSingle="true" />
</h:inputText>

The validation will still fire but if it is successful then your Bean's values will be updated.

Damo
Strange but if I use you approach, validation didn't work.
masterzim
Did you enter a value? I you have no value set the @NotNull will only be applied if you have required="true" on your UI Component (the inputText).
Damo