1

との入力があります<rich:suggestionBox>suggestionActionBeanの a で非常にうまく機能します。suggestionActionしかし、代わりにこれを JavaScript で実装したいと考えています。

これが私のコードです<rich:suggestionBox>

<h:inputText id="etabinput" />
<rich:suggestionbox height="200" width="200"
    suggestionAction="#{etablissementList.autoComplete}" var="etab" 
    for="etabinput" fetchValue="#{etab.id}    #{etab.nom}" id="suggestion" tokens=",">
    <h:column>
        <h:outputText value="#{etab.type}" />
    </h:column>
    <h:column>
        <h:outputText value="#{etab.localite}" />
    </h:column>
    <a:support ajaxSingle="true" event="onselect">
        <f:setPropertyActionListener value="#{etab}" target="#{offreHome.instance.etablissement}"/>
    </a:support>
</rich:suggestionbox>

そして、これsuggestionAction()が私のBeanのメソッドです:

public List<Etablissement> autoComplete(Object o) {
    String sql =  this.getEjbql() + " where lower(etablissement.localite) like concat(lower('"+o.toString()+"'),'%')";
    return this.getEntityManager().createQuery(sql).getResultList();   
}

毎回サーバーを呼び出さずに JavaScript からメソッドを呼び出す方法はありますか?

4

0 に答える 0