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"/>
...
RowSelected
– Hediid
field but you have an identical widgetVar for all your tableswidgetVar="tablePerformance"
which is not allowed. WidgetVar must be unique per widget. – Directed