0 Replies Latest reply on Jul 19, 2011 8:04 AM by Alberto Nipoti

    rich:select with enableManualInput="true" - handle "wrong" input

    Alberto Nipoti Newbie

      Hello,

      I'm trying to set up an "editable combo-box" using rich:select with enableManualInput="true".

       

      Apart from the issue already described in https://issues.jboss.org/browse/RF-11088, so far I'm having problems handling "wrong" user input: if the user types a value which is NOT included in the list of selectable "selectItems", I would like to restore the previous value of the field. But, I cannot find a way to attach an effective event hander (be it javascript or server-side) to be triggered in this situation.

       

      My code:

       

      <rich:select

          id="tracoChoice"

          value="#{customerActivitiesController.selectedTraco}"

          enableManualInput="true">

          <f:selectItems value="#{customerActivitiesController.selectableTracos}"/>

          <a4j:ajax event="change" execute="@this" listener="#{customerActivitiesController.onSelectedTracoChange}" render="currentCustomerActivity"/>

      </rich:select>

       

      If I select a value from the drop-down, onSelectedTracoChange() is called as expected. If I just type a random value in the input field (and then press ENTER, or TAB), onSelectedTracoChange is not called.

      I also experimented with valueChangeListener, to no avail.  On the javascript side, I tried various combinations involving onblur and onchange, but these fire for normal value selection as well. I just thought there must be a simpler way that escapes me...

       

      Alberto