tôi có trang đơn giản này:Primefaces DataTable, tải lười biếng và CommandButton mỗi hàng
<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>
và CommandButton
bên DataTable
không được làm việc, chỉ cần làm mới trang. nhưng bên ngoài đang hoạt động.
nếu tôi thay đổi value
và lazy
theo cách này:
<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>
các CommanButton
bên DataTable
công trình như một say mê.
ai đó biết lý do tại sao?
có phải là lỗi không?
tôi trên
- Glassfish 3.1.2
- JSF 2.1.11 (cá móm)
- PrimeFaces 3.4-SNAPSHOT
Đây không phải là hoàn toàn đúng: đó là hữu ích nếu cùng một ví dụ của 'LazyDataModel' được tìm thấy trong phiên bằng cách sử dụng '@ ViewScoped', nhưng bạn cũng có thể sử dụng' @ RequestScoped'. Vấn đề là phương thức 'isRowAvailable()' phải trả về true khi nó được đánh giá trong 'APPLY_REQUEST_VALUES' và trường' pageSize' phải giữ một giá trị lớn hơn 0. Tôi đã đạt được điều này bằng cách mở rộng 'LazyDataModel' trong khi nạp chồng hai phương thức:' isRowAvailable() ', ở đây tôi gọi' load (...) 'và áp dụng kết quả cho' setWrappedData() 'và phương thức thứ hai' setRowIndex (int rowIndex) 'nơi tôi đặt' pageSize' thành mặc định – uvo