Search code examples
jsfjsf-2richfacesajax4jsf

Which event to use on a <h:inputText> to cover all changes


I want to update an icon immediately while the user enters a value into a <h:inputText>.

I have the following makup:

<h:inputText id="listprice" value="#{mybean.listPrice}">
    <f:converter converterId="mybean.convertPrice"/>
    <a4j:ajax event="keyup" render="infoIcon" />
</h:inputText>

Everything works fine if I realy type the value!

However if I revisit the page and start typing in the value, my firefox offers me a list of values from my previous sessions to select and now if I select one of those values with the mouse I don't get an event!

I understand this, because there is no keyup in this case. So I bound another event handler like this:

<h:inputText id="listprice" value="#{mybean.listPrice}">
    <f:converter converterId="mybean.convertPrice"/>
    <a4j:ajax event="keyup" render="infoIcon" />
    <a4j:ajax event="mouseout" render="infoIcon" />
</h:inputText>

... and tied all kinds of events from "onchange, to onmouseout" with no sucess.

So how to I cover this "event of selecting from a browser-sugesstion-list" immediatelly ?


Solution

  • If you don't want values from user previous sessions you can use attribute autocomplete="off".

    Otherwise you can use onmouseup event, it works for me.