I have a few input fields in a form which are submitted using Save button and there is a Clear button to clear the input fields using a clear method which clears the values using setSubmittedValue(“”);
There is a selectonemenu on the top with a valueChangeListener which calls a method in backing bean to add a set of extra input fields for certain value of selectonemenu.(This field has ajax)
First I enter some values(invalid) on the input fields and click Save so that the validation fails and displays error messages.
Then I click Clear to clear the input fields and they clear.
Now if I click on selectonemenu to change its value, the input fields display the invalid values that I entered.
Is there any way to get around this issue?
You’ve set the submitted value with an empty string instead of
null. This way it will be displayed during render instead of the local value. However, on the subsequent request it becomesnullagain and the local value will be displayed instead.The clear button should have called
EditableValueHolder#resetValue()instead ofEditableValueHolder#setSubmittedValue().