I have also setup OmniFaces ResetInputAjaxActionListener on faces-config.

The bean properties field1 and field2 are Integer.

Now the issue is if I input say 123 on num1 and input 345 on num2 and click OK all okay.
If I then remove 123 from num1 and put abc on num2. Then validation (conversion) error is shown but 123 comes back!

1 Answer
1

This is a Mojarra specific issue. The field which is being bound to an Integer is implicitly been converted by the IntegerConverter which converts the submitted empty string value to null and sets it as such in the component's local value.

When a form is redisplayed after submit, JSF will first check if the submitted value is not null and then display it, else if the local value is not null, then display it, else display the model value. As the local value is null, the model value is been displayed instead. This is indeed undesired behaviour and has been reported several times:

I've re-reported this issue again. In the meanwhile, the easiest way to workaround this, while taking 3rd party component libraries with their own renderers like PrimeFaces into account, is to copy the source code file of javax.faces.component.UIInput class straight in your project's source folder and then add the desired UIInput#getValue() method. Yes, a clumsy fix, but there's not really a nicer way as the cause of the problem is deep in the JSF API itself.

The OmniFaces ResetInputAjaxActionListener serves an entirely different purpose and isn't designed/suitable to solve this problem. It is supposed to clear the state of input components of which the value of the component is not submitted, but the component itself is re-rendered in ajax.