私は以下のようにJSFページにprimefaces怠惰なデータテーブルを使用していprimefacesデータテーブルのソートアクションに更新されていない属性:あなたが見ることができるように戻るBeanが
<h:form id="searchForm">
<h:panelGroup id="searchFields">
<h:outputText value="searchField"/>
<p:inputMask
id="txtSearchField"
dir="LTR"
mask="9?999999999999"
maxlength="12"
value="#{myBackBean.searchField}" />
<h:commandButton
id="searchButton"
value="search"
action="{myBackBean.searchAction}" />
</h:panelGroup>
<p:dataTable
id="resultTable"
var="res"
value="#{res.listOfRecords}"
paginator="true" paginatorPosition="bottom" rows="10"
rowsPerPageTemplate="5,10,15"
lazy="true">
<p:column headerText="recordId" sortBy="#{res.recordId}">
<h:outputText value="#{res.recordId}" />
</p:column>
</p:dataTable>
</h:form>
、dataTableの上記検索パネルがありますは、ユーザがそれらを満たすことによって結果を絞り込むことができるパラメータを含む。以下のように、バッキングBeanの各検索フィールドに対応する属性が存在します。私は「[検索」を押すと
@Component
@Scope("request")
public class myBackBean {
private String searchField;
private LazyDataModel<RecordsDto> listOfRecords;
@Autowired
MyService myService;
public String getSearchField() {
return searchField;
}
public void setSearchField(String searchField) {
this.searchField = searchField;
}
public LazyDataModel<OperationsDto> getListOfRecords() {
return listOfRecords;
}
public void setListOfRecords(LazyDataModel<RecordsDto> listOfRecords) {
this.listOfRecords = listOfRecords;
}
public void searchAction() {
// doing the search and filling the list
listOfRecords = ...;
return listOfRecords;
}
}
バックBeanが更新されると、それは、ユーザが入力した「searchField」の値が含まれています。 しかし、 "recordId"カラムのソート矢印でグリッドをソートしようとすると、私の要求はバックビーンのgetListOfRecords()メソッドに行きますが、 "searchField"の値はnullです。
データテーブルのソートアクションで、バックフィールドの検索フィールドを更新する方法を教えてください。
[適切なBeanスコープの選択方法](https://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope) – Kukeltje