jsf - How to prevent a a null value as the new value for ValueChangedEvent? -
inside input type field have value binding variable(lets phone call foo
) of type double
value
property in jsp . have setter , getter foo
, there valuechangedlistener
registered input . autosubmit
attribute of field set true . when user clears input , navigates next field ,the code within valuechangedlistener
gets invoked , newvalue
of valuechangedevent
coming null . how can prevent ?
i tried handling setter method seems setter not getting called , valuechangedlistener
getting called first . doesn't spec setter should called first populate user edited value component , valuechangedlistener gets fired ?
p.s: using adf richinputtext input think not related adf core jsf machinery. hence not tagging adf question.
i need validate new value , not interested in old value.
a valuechangelistener
wrong tool job. utilize normal validator
. in order validate empty required fields, utilize required="true"
. in order skip custom validators on empty fields, add together next context param web.xml
:
<context-param> <param-name>javax.faces.validate_empty_fields</param-name> <param-value>false</param-value> </context-param>
the disadvantage skip @notnull
/@notblank
jsr303 bean validation, shouldn't harm if aren't using anyway.
also why setter won't called before valuechangelistener
?
because old value otherwise lost , defeat purpose of value alter listener.
will validator run before valuechangedlistener ? guess when validation passes , should invoke valuechangedevent , right ?
that's correct. value alter listener invoked when component has passed validation (i.e. uiinput#isvalid()
returns true
). noted should 1 time again when you're not interested in old value, value alter listener wrong tool job had in mind.
jsf jsf-2
No comments:
Post a Comment