p:selectionMode为倍数的数据表 [英] p:datatable with selectionMode as multiple

查看:154
本文介绍了p:selectionMode为倍数的数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据素数文档,所选内容应为数组.在下面的代码中,bean.selectedUsers定义为"HasUsersVO [] selectedUsers",但数据表的值为List.填充数据表后,单击确定"按钮时,我在底部粘贴了强制转换错误.

As per the primefaces document the selection should be a array. In the below code bean.selectedUsers is defined as "HasUsersVO[] selectedUsers" but the value of datatable is List. I am getting cast error as pasted at the bottom when i click the OK button after the datatable got filled.

                <p:dataTable id="userListTable" value="#{bean.peopleVOList}"
                    var="user" rowClasses="odd even" selection="#{bean.selectedUsers}" rowKey="#{user.userGuid}"
                    <p:column selectionMode="multiple" style="width:18px">
                    </p:column>
.....
.....
</p:dataTable>

错误

22:59:16,962 INFO  [class com.zreflect.emyed.managedbean.circle.CircleController] (http--127.0.0.1-8080-3) *******************Outside getUsersList********************
22:59:38,943 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-3) [Lcom.user.PeopleVO; cannot be cast to java.util.Collection: java.lang.ClassCastException: [Lcom.user.PeopleVO; cannot be cast to java.util.Collection
    at org.primefaces.component.datatable.DataTable.getRowData(DataTable.java:835) [primefaces-3.3.1.jar:]
    at org.primefaces.component.datatable.DataHelper.decodeMultipleSelection(DataHelper.java:262) [primefaces-3.3.1.jar:]
    at org.primefaces.component.datatable.DataHelper.decodeSelection(DataHelper.java:240) [primefaces-3.3.1.jar:]
    at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:72) [primefaces-3.3.1.jar:]

推荐答案

异常消息和堆栈跟踪指示您在#{bean.peopleVOList}之后提供了PeopleVO[]数组.这个不对.它必须是Collection,最好是ArrayList<PeopleVO>.

The exception message and the stacktrace indicates that you've supplied a PeopleVO[] array behind #{bean.peopleVOList}. This is not right. It must be a Collection, preferably an ArrayList<PeopleVO>.

private List<PeopleVO> peopleVOList;

#{bean.selectedUsers}实际上必须是PeopleVO[].那部分很好.

The #{bean.selectedUsers} must indeed be an PeopleVO[]. That part is fine.

这篇关于p:selectionMode为倍数的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆