Html 使用richfaces在客户端自动完成
我有一个客户表,我试图在搜索时使用autocomplete。问题是,尽管只有大约3000名客户,但自动完成搜索建议框的显示大约需要2-3秒。 我考虑创建一个var,它将包含页面加载时创建的所有客户,当有人搜索客户时,搜索将只在客户端进行。 我不知道如何在RichFaces中做到这一点。请帮忙 到目前为止我所拥有的(从服务器缓慢搜索)-customerSuggestBox.xhtmlHtml 使用richfaces在客户端自动完成,html,autocomplete,richfaces,Html,Autocomplete,Richfaces,我有一个客户表,我试图在搜索时使用autocomplete。问题是,尽管只有大约3000名客户,但自动完成搜索建议框的显示大约需要2-3秒。 我考虑创建一个var,它将包含页面加载时创建的所有客户,当有人搜索客户时,搜索将只在客户端进行。 我不知道如何在RichFaces中做到这一点。请帮忙 到目前为止我所拥有的(从服务器缓慢搜索)-customerSuggestBox.xhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitio
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:s="http://jboss.com/products/seam/taglib">
<ui:composition>
<ui:define name="forItem">customerText</ui:define>
<rich:suggestionbox for="${forItem}" tokens=",["
suggestionAction="#{customerUtilAction.getCustomersByName}" var="cus"
selfRendered="true"
ignoreDupResponses="true"
fetchValue="#{cus.businessUnit.name}"
first="0"
minChars="2"
shadowOpacity="5"
border="1" width="400"
height="250"
onselect="setCaretToEnd(event);"
reRender="#{reRender}"
shadowDepth="1"
cellpadding="5" cellspacing="1" nothingLabel="No customers found" columnClasses="center">
<h:column>
<h:outputText value="#{cus.businessUnit.name}" />
</h:column>
<h:column>
<h:outputText value="#{messages[cus.businessRelationship.name()]}" />
</h:column>
<ui:insert name="reRender"></ui:insert>
</rich:suggestionbox>
</ui:composition>
</html>
客户文本
忘了说:
另一个xhtml包括这个xhtml,并向其发送参数“forItem”
2-3秒的延迟可以是一切。。数据库查询是否有效?业务逻辑有效吗?(我有一个缓慢的数据库层,通过“加载”gif来解决它,以向用户显示发生了什么事情)是的,也许我应该提到,查询是有效的,数据库一切正常。我考虑过“加载”gif,但如果可能的话,我更喜欢更改自动完成。
<ui:include src="customerSuggestBox.xhtml">
<ui:param
name="forItem"
value="customerText" />
</ui:include>