PrimeFaces multiple DataTables and rowselect event
Asked Answered
G

0

6

I have a dynamic list of data tables and I need to enable row selection for a single row of each table. The code below works only if the user selects a row of the last data table, maybe because the Ajax event is replaced and only last event works.

If the user selects a row from another data table, onRowSelect method is called but there is a NullPointerException on variable selectedRow.

Maybe I need to create multiple onrowselect method in Java bean,one for each data table, but the number of this table is variable.

How can I solve this issue?

<c:forEach items="#{azPerformancePrenPubAll.selectedCompanyTemp}" var="companyCode" varStatus="loop">
  <p:accordionPanel id="acc_#{companyCode}" widgetVar="accordionAziendale_#{companyCode}" activeIndex="-1"> 
    <p:tab title="#{azPerformancePrenPubAll.selectedCompanyName.get(loop.index)}">             
       <p:dataTable id="tablePerformance_#{companyCode}" rendered="#{!azPerformancePrenPubAll.isCompanyVisible}"
                    widgetVar="tablePerformance" var="performance" value="#{azPerformancePrenotatiPubAll.listPerformances.get(loop.index)}" 
                    styleClass="perfDataTable no-border" rowIndexVar="rowIndex" 
                    selectionMode="single" selection="#{azPerformancePrenPubAll.selectedRow}" rowKey="#{performance.id}">
         <p:ajax event="rowSelect" listener="#{azPerformancePrenPubAll.onRowSelect}" update="formPerformance,pageSubDescription,pageDescription"/>
         ...
Gros answered 1/9, 2023 at 23:58 Comment(3)
I don't see a variable RowSelectedHedi
@JasperdeVries sorry I misspelled the variable name, I edited the post. the variable is specified in the selection attribute of the datatable, it's 'selectedRow'Gros
You are using mutliple tables and you renamed the id field but you have an identical widgetVar for all your tables widgetVar="tablePerformance" which is not allowed. WidgetVar must be unique per widget.Directed

© 2022 - 2024 — McMap. All rights reserved.