简体   繁体   English

当c:foreach中有多个p:datatable时,带有选定对象的事件rowselect为null

[英]event rowselect with selected object null when multiple p:datatable in c:foreach

I have a list of p:datatables, for each I need row selection event. 我有一个p:datatables列表,每个列表都需要行选择事件。 But only last datatable works. 但是只有最后一个数据表有效。 If I select a row in others datatables I see that onRowSelected method is called, but object is null. 如果我在其他数据表中选择一行,则会看到调用了onRowSelected方法,但是object为null。

I think that in c:foreach the ajax listener is overwritten, so only last works. 我认为在c:foreach中,ajax侦听器将被覆盖,因此只有最后一种有效。 How to solve ? 怎么解决 ?

this is my xhtml code: 这是我的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"/>
    ....

I solved. 我解决了 widgetVar is equal in loop, I need to set different id in widgetVar widgetVar在循环中是相等的,我需要在widgetVar中设置不同的ID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM