富:在JavaScript中带有suggestionAction的suggestionBox

时间:2011-10-24 11:41:17

标签: javascript jsf richfaces seam2

我有<rich:suggestionBox>的输入。它适用于bean中的suggestionAction。但我想在JavaScript中实现此suggestionAction

以下是我<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>

这是我的bean中的suggestionAction()方法:

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调用方法而不必每次都调用服务器?

0 个答案:

没有答案