0
我有一個奇怪的問題,我確信它與h:表單置標籤有關。我有一個表格,在表格上方有一個搜索表單,我可以在其中放置一些標籤,例如名稱或姓氏,之後表格將被刷新。它的工作!但由於某些原因,它只是停止工作,我不知道爲什麼。現在爲了檢查搜索結果,我必須刷新頁面或將表格中的分頁從10更改爲15,然後顯示結果。下面是一些代碼:表格不想在輸入搜索標籤後更新
XHTML:
<h:form>
<div class="row">
<div class="panel-heading text-center">
<div class="bootstrap-filestyle input-group inn">
<div class="search-criteria" style="width: 500px">
<h:inputText value="#{clientBean.tags}" styleClass="form-control"
type="text">
<f:passThroughAttribute name="placeholder"
value="Imię, nazwisko, adres..." />
</h:inputText>
</div>
<p:commandButton type="submit" style="float:left"
styleClass="btn btn-primary" value="Szukaj"
actionListener="#{clientBean.getAllClients()}">
<i class="icon-search icon-white"></i>
</p:commandButton>
</div>
</div>
</div>
<h:form>
<p:dataTable id="clientsTable" style="white-space: nowrap"
var="client" value="#{clientBean.getAllClients()}" paginator="true"
rows="15"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,15">
<p:column headerText="Imię">
<h:outputText value="#{client.name}" />
</p:column>
<p:column headerText="Nazwisko">
<h:outputText value="#{client.lastName}" />
</p:column>
<p:column headerText="Numer telefonu">
<h:outputText value="#{client.phoneNumber}" />
</p:column>
<p:column headerText="Adres">
<h:outputText value="#{client.address}" />
</p:column>
<p:column>
<a href="klienci/#{client.ID}"
class="btn btn-success edit resized-font"><span
class="glyphicon glyphicon-pencil"></span> Edytuj</a>
<a href="klienci/#{client.ID}"
class="btn btn-danger delete resized-font"><span
class="glyphicon glyphicon-trash"></span> Usuń</a>
<a href="klienci/#{client.ID}" class="btn btn-primary resized-font"><span
class="glyphicon glyphicon-book"></span> Informacje</a>
</p:column>
</p:dataTable>
</h:form>
</h:form>
從ClientBean重要代碼:
你犯下違反W3C XHTML規範的private String tags;
public Set<Client> getAllClients() {
if (tags == null) {
Set<Client> clients = new HashSet<Client>(clientDao.findAll());
return clients;
}
return getClients();
}
public Set<Client> getClients() {
Set<Client> mergedClientSet = new HashSet<>();
String[] tags = getTags().split(" ");
for(int i=0; i<tags.length; i++){
mergedClientSet.addAll(searchService.getClientWithParameters(tags[i]));
}
return mergedClientSet;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}