【问题标题】:event rowselect with selected object null when multiple p:datatable in c:foreach当 c:foreach 中有多个 p:datatable 时,事件 rowselect 与选定对象为 null
【发布时间】:2019-11-17 20:46:45
【问题描述】:

我有一个 p:datatables 列表,每个我需要行选择事件。 但只有最后一个数据表有效。 如果我在其他数据表中选择一行,我会看到调用了 onRowSelected 方法,但 object 为 null。

我认为在 c:foreach 中,ajax 监听器被覆盖,所以只有 last 有效。 如何解决?

这是我的 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"/>
    ....

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    我解决了。 widgetVar 在循环中是相等的,我需要在 widgetVar 中设置不同的 id

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-26
      • 1970-01-01
      • 2013-01-15
      • 2020-05-03
      • 1970-01-01
      • 2015-01-25
      • 2016-08-06
      • 2013-08-29
      相关资源
      最近更新 更多