This functionality was working in PF8 but after upgrading to PF10 it is now broken
Scenario as follows:
I have a main single selection datatable(Table 1, ekeys). I have a secondary multi selection datatable(Table 2, groupsTable) that displays a list of rows. Depending on the selection from Table1, i want to auto-select a number of rows in Table2 based on some business logic. This is working.
What is not working is that when I select a different row from Table1, Table 2 stills shows the rows associated to the previous selection AND the rows from the current selection. I can confirm that my logic in the controller has the expected values in the objects relating to the selection variable of Table2.
But the in the DataTableRender class i can see the rowkeys for that table still contain the rowkey for the previous selection. Then the new rowkeys are added and I see the combined set of highlighted rows. If i click a third row in Table1 then same happens again.
I have tried, calling the unselectAllRows method in the onstart of my <p:ajax command. But there appears a PF10 bug with unselectAllRows in that it does not clear the rowkeys value but rather just un-highlights the row.
I tried calling it from the java side but then it gets executed after the logic to the next selected row and so ends up clearing everything instead of the previous.
I created my own DataTableRenderer class and override a method and forced the rowkey of the table to null everytime. This worked but broke another use case where i have another Table1 but its multi-selection instead of single selection so i actually want the previous values kept!
I have tried setting the selectedEkey variable to null or empty but still the rows remain selected.
Running out of ideas on how to handle this. Primefaces seem to have decided to give you a pretty broken first major release and then charge you to fix the many regression bugs they introduce.
xhtml Table1
<h:form id="eKeyListForm">
<p:dataTable id="ekeys" value="#{eKeyController.lvList}"
var="ekey" selectionMode="single"
selection="#{eKeyController.selectedEKey}"
scrollable="true"
rows="25"
paginatorPosition="bottom"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
currentPageReportTemplate="{startRecord}-{endRecord} #{i18n_layout.paginator_from} {totalRecords} | #{i18n_layout.paginator_page} {currentPage} #{i18n_layout.paginator_of} {totalPages}"
rowsPerPageTemplate="5,10,15,20,25"
resizableColumns="true"
rowKey="#{ekey.id}">
<p:ajax event="rowSelect" process="@this" update=":hw-editmenu:hw-emf :dlgSaveComp:dlgAskSaveForm :dlgDeleteComp:dlgAskDeleteForm :eKeyListForm :tabView:groupsForm:groupsTable" />
xhtml Table 2
<h:form id="groupsForm">
<hw:dataTable id="groupsTable"
widgetVar="groupsTable"
var="ug"
value="#{eKeyController.childGroups}"
selection="#{eKeyController.selChildGroups}"
rowKey="#{ug.id}"
multiselect="true"
rowSelectMode="add"
scrollable="false">
<p:ajax event="rowSelect" listener="#{eKeyController.onChildGroupRowSelect}" update=":hw-editmenu:hw-emf"/>
<p:ajax event="rowUnselect" listener="#{eKeyController.onChildGroupRowUnselect}" update=":hw-editmenu:hw-emf"/>
<p:ajax event="rowSelectCheckbox" listener="#{eKeyController.onChildGroupRowSelect}" update=":hw-editmenu:hw-emf"/>
<p:ajax event="rowUnselectCheckbox" listener="#{eKeyController.onChildGroupRowUnselect}" update=":hw-editmenu:hw-emf"/>
<p:ajax event="toggleSelect" listener="#{eKeyController.onChildGroupToggleSelect}" update=":hw-editmenu:hw-emf"/>
Backing Bean
public void setSelectedEKey(IEKey selectedEKey) {
if (!this.isChanged) {
this.selectedEKey = selectedEKey;
nextSelected = null;
refreshSelectedChildGroups();
} else {
this.nextSelected = selectedEKey;
PrimeFaces.current().executeScript("PF('dlgAskSaveWidget').show()");
}
}
private void refreshSelectedChildGroups() {
if (selectedEKey != null) {
this.setSelChildGroups(selectedEKey.getUserGroups());
} else {
this.setSelChildGroups(new ArrayList<>());
}
PrimeFaces.current().ajax().update(Arrays.asList("tabView:groupsForm:groupTable"));
}
Any thoughts on how to get the rowkey selection in Table2 cleared each time?