Inside an input type field I have a value binding to a variable(lets call foo) of type double for the value property in my jsp . I have a setter and a getter for foo and there is also a ValueChangedListener registered for this input . The autosubmit attribute of that field is set to true . When the user clears the input and navigates to the next field ,the code inside valueChangedListener gets invoked and the newValue of the ValueChangedEvent is coming null . How can I prevent this ?
I tried handling this from the setter method but it seems the setter is not getting called and the valueChangedListener is getting called first . Doesn’t the spec say that setter should be called first to populate the user edited value to the component and then only the ValueChangedListener gets fired ?
P.S: I am using ADF RichInputText as the input but I think it is not related to ADF but to core JSF machinery. Hence not tagging it as ADF question.
A
valueChangeListeneris then the wrong tool for the job. Use a normalValidator. In order to validate empty but required fields, userequired="true". In order to skip custom validators on empty fields, add the following context param toweb.xml:The only disadvantage is that this will also skip
@NotNull/@NotBlankJSR303 bean validation, but that shouldn’t harm if you aren’t using it anyway.Because the old value is otherwise lost and this would defeat the purpose of the value change listener.
That’s correct. The value change listener is only invoked when the component has passed validation (i.e.
UIInput#isValid()returnstrue). Noted should be again that when you’re not interested in the old value, the value change listener is most likely the wrong tool for the job you had in mind.