jsf - 当 c:foreach 中有多个 p:datatable 时,事件 rowselect 与选定对象为 null
问题描述
我有一个 p:datatables 列表,每个我需要行选择事件。但只有最后一个数据表有效。如果我在其他数据表中选择一行,我会看到调用了 onRowSelected 方法,但对象为空。
我认为在 c:foreach 中,ajax 侦听器被覆盖,所以只有最后一个有效。怎么解决 ?
这是我的 xhtml 代码:
<c:forEach items="#{azPrimaDisponibilita.selectedCompany}" var="companyCode" varStatus="loop">
<p:dataTable id="tablePerformance_#{companyCode}" rendered="#{azFirstAvail.isCompanyVisible}" widgetVar="tablePerformance" var="performance" value="#{azFirstAvail.listPerformances.get(loop.index)}"
styleClass="perfDataTable no-border" rowIndexVar="rowIndex"
selectionMode="single" selection="#{azFirstAvail.selectedRowCompany}" rowKey="#{performance.id}">
<p:ajax event="rowSelect" global="true" listener="#{azFirstAvail.onRowSelectCompany}" update="formPerformance,pageSubDescription,pageDescription"/>
....
解决方案
我解决了。widgetVar 在循环中是相等的,我需要在 widgetVar 中设置不同的 id
推荐阅读
- html - 如何在离子内容中滚动到底部
- ruby-on-rails - Websocket 仅适用于 ws:// 但不适用于 wss://
- django - 带有 Django 的 Amazon SES 不在 UTC 时区
- javascript - 使用 JavaScript 清除多选下拉菜单
- php - Php 阵列 6 x 6 爆炸
- python - pywinauto 不将控件标识为 TabControl
- javascript - ag-grid - 数据更改时调整细节高度
- node.js - 如何在sequelize中从父表中获取数据
- php - 仅显示不在某个表中的值。MySQL
- react-native - 在 React Native 中从 Fire 库中读取特定值