primefaces3.0数据表选择和value属性

发布于 2024-12-25 21:10:45 字数 924 浏览 1 评论 0原文

我已将我的项目从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鲸落 2025-01-01 21:10:45

在 Primefaces 2.2 中,选择会自动更新其 bean 值,但这可能并不适合所有情况,因此在 3.0 中,他们更改了它,以便要发生 ajax 回发,您需要放置一个 ; 标签,在 dataTable 中带有 rowSelect 事件。

<p:dataTable id="table1" ... >
  <p:ajax event="rowSelect" update="formid:table1 formid:table2" oncomplete="dlg.show()" />
  ...
</p:dataTable>

<p:dataTable id="table2" ... >
  ...
</p:dataTable>

第一个数据表的选择应该触发第二个数据表的服务器回发和部分页面更新。

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 a rowSelect event within the dataTable.

<p:dataTable id="table1" ... >
  <p:ajax event="rowSelect" update="formid:table1 formid:table2" oncomplete="dlg.show()" />
  ...
</p:dataTable>

<p:dataTable id="table2" ... >
  ...
</p:dataTable>

Selections of the first dataTable should trigger the server postback and partial page update of your second dataTable.

旧夏天 2025-01-01 21:10:45

我认为您应该尝试在第一个 中添加 selectionMode="multiple" ,并在第一个 中添加 selectionMode="single"第二个

I think you should try to add selectionMode="multiple" in your 1st <p:dataTable> and selectionMode="single" in your 2nd <p:dataTable>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文