rich:suggestionBox 与 JavaScript 中的 suggestAction
我有一个输入
。它与 bean 中的 suggestionAction
配合得很好。但我想用 JavaScript 实现这个 suggestionAction
。
这是我的
的代码:
<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 调用该方法,而无需每次都调用服务器吗?
I have an input with <rich:suggestionBox>
. It works very well with a suggestionAction
in the bean. But I want to implement this suggestionAction
in JavaScript instead.
Here is the code of my <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>
And here is the suggestionAction()
method in my 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();
}
Is there a way to call the method from JavaScript without invoking the server each time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论