Method being called several times in the change event of a p: ajax

1

I have a table with a p:inputText with a p:ajax inside, it has the change event, when I fill that inputText with a value a query and some validations are performed. The problem is that when I put a value inside that inputText (ctrl + v) the method is called twice. If I type the value in inputText rather than paste it the method works the right way, ie it is called only once.

xhtml :

<p:inputText id="codigoFunInput" label="Código"
   mask="9?999999999" maxlength="7" slotChar=""
   readonly="#{!item.novoFuncionario}"
   style="width:100%;text-align:" value="#{item.codigo}">
   <p:ajax event="change"
      listener="#{mbean.carregaNomeFuncionario(item)}"
      process="@this" partialSubmit="true"
      update="dataTableResponsaveis, :formTopo:topoMessage" />
</p:inputText>

What might be "spoiling" this ajax request? I have other ajax events on the screen, but they do serve other things.

Note: On the screen I also have some decorates on the screen too, I do not know this can influence.

    
asked by anonymous 10.05.2017 / 17:00

1 answer

3

Probably the event of the event="change" attribute is being triggered in the keyUp of the keyboard, as ctrl + v are two keys, so there will be 2 events. Test using the delay attribute of p: ajax

<p:ajax delay="1000" event="change"  
  listener="#{mbean.carregaNomeFuncionario(item)}"
  process="@this" partialSubmit="true"
  update="dataTableResponsaveis, :formTopo:topoMessage" />
    
10.05.2017 / 20:15