命令按鈕,我有這個簡單的頁面:Primefaces數據表,延遲加載和每
<h:form id="form">
<p:dataTable value="#{testBean.unitTypeModel}" var="elem" lazy="true" rows="10">
<p:column headerText="class">#{elem.class.simpleName}</p:column>
<p:column headerText="code">#{elem.code}</p:column>
<p:column headerText="description">#{elem.description}</p:column>
<p:column headerText="action">
<p:commandButton action="test2" icon="ui-icon ui-icon-wrench" value="edit">
<f:setPropertyActionListener target="#{testBean.selection}" value="#{elem}"/>
</p:commandButton>
</p:column>
</p:dataTable>
<p:commandButton action="test2" icon="ui-icon ui-icon-wrench"/>
</h:form>
和內部DataTable
的CommandButton
不工作,只是刷新頁面。 但外面正在工作。
如果我改變value
和lazy
這樣:
<h:form id="form">
<p:dataTable value="#{testBean.unitTypeModel.load(0, 10, null, null, null)}" var="elem" lazy="false" rows="10">
<p:column headerText="class">#{elem.class.simpleName}</p:column>
<p:column headerText="code">#{elem.code}</p:column>
<p:column headerText="description">#{elem.description}</p:column>
<p:column headerText="action">
<p:commandButton action="test2" icon="ui-icon ui-icon-wrench" value="edit">
<f:setPropertyActionListener target="#{testBean.selection}" value="#{elem}"/>
</p:commandButton>
</p:column>
</p:dataTable>
<p:commandButton action="test2" icon="ui-icon ui-icon-wrench"/>
</h:form>
的CommanButton
內DataTable
的作品就像一個魅力。
有人知道爲什麼嗎?
它是一個錯誤?
我是在
- Glassfish的3.1.2
- JSF 2.1.11(鑽嘴魚科)
- PrimeFaces 3.4快照
這是不完全正確會話通過使用'@ ViewScoped',但您也可以使用'@ RequestScoped'。重點在於,當在'APPLY_REQUEST_VALUES'中計算'isRowAvailable()'方法並且'pageSize'字段必須保存大於零的值時,它必須返回true。我通過在重載兩個方法的同時擴展'LazyDataModel'來實現這一點:'isRowAvailable()',在這裏我調用'load(...)'並將結果應用於'setWrappedData()',第二個方法'setRowIndex(int rowIndex) '我把'pageSize'設置爲我的默認值 – uvo 2018-01-16 10:14:28