にhtmlとして行をレンダリングします。最初のビューはさまざまなフィルタを持つ検索パネルのみをレンダリングし、検索のクリックでユーザーテーブルが照会され、データセットが返され、ブロックがdatatable
を含むビューでレンダリングされます。以下は、検索ユーザーのためのlazyloadingコードです。Primefaces遅延読み込みは、私はJSF 2.2が</strong><strong>、<strong>Primefaces 6.1</strong>を持つ単一ページのアプリケーションを構築し、ユーザーを検索するためのオプションを持っている<strong>Wildfly</strong>、上でそれを実行していますページネーション
public void getUsers(ActionEvent event) {
//few lines to get filterData
this.lazyUsers = new LazyDataModel<UserModel>() {
private static final long serialVersionUID = 1L;
@Override
public List<UserModel> load(int first, int pageSize, String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
filterObject.setStartCount(new Long(first));
filterObject.setCountPerPage(new Long(pageSize));
List<UserModel> list = userService.getUsers(filterObject);
if (list != null)
this.setRowCount(list.get(0).getTotalNumberOfRecords().intValue());
RequestContext context = RequestContext.getCurrentInstance();
if(context!=null)
context.addCallbackParam("totalRecords", this.getRowCount());
return list;
}
};
}
と私のテーブルビューです。
<p:outputPanel id="users" autoUpdate="true">
<p:outputPanel rendered="#{users.displayusers}">
<h5 class="title">
<h:outputText value="#{msg.header_title}"></h:outputText>
</h5>
<p:dataTable id="userTable" lazy="true" paginator="true"
rows="2"
emptyMessage="#{msg.emtpymsg}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="2,4,5"
rendered="#{null != users.lazyUsers && not empty users.lazyUsers }"
value="#{users.lazyUsers}" var="user"
rowIndexVar="userRow">
<p:column headerText="#{msg.Name}">
<h:outputLabel class="tdRow" value="#{user.name}" />
</p:column>
<p:column headerText="#{msg.Phone}">
<h:outputLabel class="tdRow" value="#{user.phone}" />
</p:commandLink>
</p:column>
<p:column headerText="#{msg.Address}">
<h:outputLabel class="tdRow" value="#{user.address}" />
</p:column>
<p:column headerText="#{msg.Email}">
<h:outputLabel class="tdRow" value="#{user.email}" />
</p:column>
</p:dataTable>
</p:outputPanel>
</p:outputPanel>
検索が発生したときにすべてがレンダリングが、私はページ付けたときに、それは、次のページのデータを検索し、次のページデータを取得しますが、それはデータテーブルを削除する通常のHTMLとしてそれをレンダリングします。 htmlの検査では、ネットワークタブ内のサーバからの応答としてtr
とtd
としか表示されず、その中のコンテンツだけがdiv
に直接描画されます。データテーブルは保存されません。誰でも私にここで起こっていることを教えてもらえますか?
私もdatatable
内ページイベントをキャプチャしようとしましたが、それは助けにはならなかった
<p:ajax event="page" update="userContainer:userTable"></p:ajax>
が、再びとしてupdate
価値を追加しました。いくつかの助けを見つけることを願っています。
更新が
私は気づいた、これは、ソート、フィルタリング、同様に、datatables
を通じて任意のAJAX操作のために起こる、rowsperpageなどを変更し、これで間違っている正確に何に識別するための方法はあります?
[Primefaces Datatable display bug]の複製があります(https://stackoverflow.com/questions/44270955/primefaces-datatable-display-bug) – Kukeltje
@Kukeltje問題は彼と幾分似ていましたが解決策が使用されていました'update'ではなく' pagination 'ajax'で' process'を実行します。私は私の質問を更新し、同じ答えを追加しました。ありがとうございました.. :) –