我正在研究javaee7 / primefaces 4.0应用程序。
在我的页面中,我使用已渲染的自动完成功能,但是当我运行应用程序自动填充功能时,它不显示建议但未完成。请帮帮我:(
的index.xhtml
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head><title> for test application </title></h:head>
<h:body>
<h:form>
<div class="btn1"> <p:commandButton value="food" type="button" onclick="lazyload()" id="btnfood" /> </div>
<div class="block1">
<p:outputPanel id="lazypanel" layout="block">
<p:autoComplete value="#{autoCompleteBean.txt1}" completeMethod="#{autoCompleteBean.complete}" rendered="#{requestScope.shouldRender2}"/>
<p></p>
<p:commandButton value="cancel" type="button" onclick="lazyload2()" id="non-btnfood" rendered="#{requestScope.shouldRender2}" />
</p:outputPanel>
<p:remoteCommand name="lazyload" update="lazypanel">
<f:setPropertyActionListener value="#{true}"
target="#{requestScope.shouldRender2}" />
</p:remoteCommand>
<p:remoteCommand name="lazyload2" update="lazypanel">
<f:setPropertyActionListener value="#{false}"
target="#{requestScope.shouldRender2}" />
</p:remoteCommand>
</h:form>
</h:body>
和我的豆子
public class AutoCompleteBean implements Serializable{
private String txt1;
public List<String> complete(String query) {
List<String> results = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
results.add(query + i);
}
return results;
}
public String getTxt1() {
return txt1;
}
public void setTxt1(String txt1) {
this.txt1 = txt1;
}
}