<h:form id="searchForm">
Keyword: <p:inputText id="search"
value="#{employeeSearch.searchString}" />
<p:commandButton value="Search"
action="#{employeeSearch.searchByString}">
<f:ajax execute="@all" render="output" />
</p:commandButton> (Enter keywords separated by spaces)
<p:dataTable id="output" var="employee"
value="#{employeeSearch.employees}">
... etc...
我知道数据库在第一次点击按钮后被点击,只是视图没有被Ajax更新
如果我将ajax="false"
添加到commandButton <p:commandButton value="Search" ajax="false"
只需点击一下按钮或点击输入一次,整个页面就会刷新,数据表会按预期更新。
这是我的豆子
@ViewScoped
@ManagedBean
public class EmployeeSearch {
public String searchByString() {
this.employees = employeeRepository.searchBySingleString2(searchString);
return null;
}
答案 0 :(得分:1)
如果您只想更新dataTable组件,请尝试执行以下操作:
<p:commandButton value=" action="#{employeeSearch.searchByString}" update="output">
或只是添加commandButton
<f:ajax update=":searchForm:output" />