开发者

JSF datatable row selection

开发者 https://www.devze.com 2022-12-25 18:53 出处:网络
How to s开发者_Python百科elect multiple rows in a JSF datatable?You can either place a checkbox on each row giving it a value of #{currentRowItem.selected} or use <rich:extendedDataTable>Create

How to s开发者_Python百科elect multiple rows in a JSF datatable?


You can either place a checkbox on each row giving it a value of #{currentRowItem.selected} or use <rich:extendedDataTable>


Create a Map<Integer, Boolean> selectMap in the backing bean. (If the key is not model's id and key is a string, create a Map with String, Boolean pair ..)

For every row provide a checkbox #{backingBean.selectMap[rowvar.selectedId]} You must be able to find the selected values in the map after each selection.


you can use primefaces as follow:

<p:dataTable id="tableId" var="data" value="#{myBean.myList}" 
          selection="#{myBean.selectedDTOs}"               
          rowKey="#{data.objectId}">
        <p:column selectionMode="multiple" />
</p:dataTable>
0

精彩评论

暂无评论...
验证码 换一张
取 消