Search code examples
jsfjsf-2

JSF ajax event delay


I want to implement a live filter for a list with JSF 2 but when using keyup event so many requests are being sent to the server. The code looks like:

<h:inputText id="filter_input" value="#{bean.filterText}">
    <f:ajax event="keyup" listener="#{bean.filter}" 
        render="@form:list" execute="@this" />
</h:inputText>

Solution

  • f:ajax has added support for ajax event delay starting from JSF 2.2. Just include it as an attribute with its value in miliseconds:

    <f:ajax event="keyup" delay="1000" listener="#{someBean.doSomething}"
        render="somefield" execute="@this" />
    

    See also: