I need a listener function to be able to detect when a user clears an inputText field. When the text field has a new string entered into it, the backing bean value is immediately updated and then the listener function is called, however, by debugging I have noticed that when a string is cleared the backing bean variable isn't set to null till after the listener has returned. As my listener function relies upon a (backingBeanvariable == null) test this is causing errors in my functionality. Is there a way to get around this?
My xhtml:
<p:column>
<p:inputText id="inputText" value="#{backingBean.variable}"
title="someTitle">
<p:ajax resetValues="true" listener="#{backingBean.onChange()}" />
</p:inputText>
</p:column>
Backing Bean listener Function:
public void onUiiTypeChange()
{
if (variable == null)
{
// some logic
}
}
EDIT: The variable may get set to an empty string reather than null when a field is cleared. Either way, this doesn't occur until after the listener function has returned. i.e. if the field contained "asdf" before it was cleared the variable will still be set to "asdf" when the listener function is called.