primefaces3.0数据表选择和value属性
我已将我的项目从 Primefaces 2.2 升级到 3.0
我在数据表中遇到问题。我有一个数据表,其值通过列表填充,并且选定的行保存在数组中
<p:dataTable id="datavalues" value="#{bean.list}"
var="o" paginator="true" rows="10"
selection="#{bean.selected1}"
rowKey="#{o.property1}" >
,现在我希望选定的行在另一个数据表中使用,并且在该数据表上我使用了值“#{bean.selected1}”和选择作为#{bean.selected2},因为我还需要从此表中选择的值。
<p:dataTable id="table4" var="o" value="#{bean.selected1}"
rows="10"
selection="#{bean.selected2}"
rowKey="#{o.property2}"
>
我得到的异常是:
[Lcom.packagedirectory.beans.beanHelper; cannot be cast to java.util.Collection
list、selected1、selected2 都是 beanHelper 类的属性。 这段代码在 2.2 上完美运行,与它有关吗?值也是一个数组,选择也是一个数组。
I have upgraded my project from Primefaces 2.2 to 3.0
I am facing problems in Datatable. I have a Datatable whose values i am populating through a list and selected rows are kept in array
<p:dataTable id="datavalues" value="#{bean.list}"
var="o" paginator="true" rows="10"
selection="#{bean.selected1}"
rowKey="#{o.property1}" >
now i want the selected rows to be used in another Datatable and on that Datatable i have used values as "#{bean.selected1}" and selection as #{bean.selected2} as i also need the selected values from this Table.
<p:dataTable id="table4" var="o" value="#{bean.selected1}"
rows="10"
selection="#{bean.selected2}"
rowKey="#{o.property2}"
>
The Exception I got is :
[Lcom.packagedirectory.beans.beanHelper; cannot be cast to java.util.Collection
list, selected1, selected2 are all properties of beanHelper Class.
This code was perfectly working on 2.2 Has it something to do with That value is also an array and selection is also an array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Primefaces 2.2 中,选择会自动更新其 bean 值,但这可能并不适合所有情况,因此在 3.0 中,他们更改了它,以便要发生 ajax 回发,您需要放置一个
;
标签,在 dataTable 中带有rowSelect
事件。第一个数据表的选择应该触发第二个数据表的服务器回发和部分页面更新。
In Primefaces 2.2 the selection would have updated its bean value automatically, however this was probably not desirable for every situation, so in 3.0 they changed it so that for an ajax postback to occur you need to place a
<p:ajax>
tag with arowSelect
event within the dataTable.Selections of the first dataTable should trigger the server postback and partial page update of your second dataTable.
我认为您应该尝试在第一个
中添加selectionMode="multiple"
,并在第一个
中添加selectionMode="single"
第二个
。I think you should try to add
selectionMode="multiple"
in your 1st<p:dataTable>
andselectionMode="single"
in your 2nd<p:dataTable>
.