0

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?

  • We did not decide to release something broken but we decided to finally do a big DataTable refactoring since many years and just had not enough integration tests. Maybe you could honor our work in a opensource project in our sparetime a bit.... Nevertheless - now we have around 30 Testcases. So just give 11.0.RC2 a try and otherwise create a reproducer and issue on your side. – tandraschko Nov 17 '21 at 17:36
  • My primefaces comment was frustration and I apologise. But moving to yet another major release is not really what we want to do. This is major client project and upgrading to PF10 was meant to be the goal. Who is to say what is broken in v11. What if I upgrade to 11 and find other regressions, what then? – R.Quinlan Nov 18 '21 at 08:21
  • just test next time when a RC1 gets released, then you have a high change that we fix your bugs till final.... – tandraschko Nov 18 '21 at 08:22
  • That still means i have to do a migration to another major release. That should not be needed. Which involves yet more code churn. I did try RC11 but backed off because of changes in other components that i would have to change code just to work with v11 – R.Quinlan Nov 18 '21 at 11:06
  • @R.Quinlan Your other choice is to pay for PRO support and get it fixed in a 10.0.X Elite release. You can also patch the code yourself with the fixes from 11.0. Lots of options. But 11.0.0 is probably your easiest path and has fixed tons of issues and we went from 0 integration tests to over 500+ passing Integration tests to improve quality between major releases. – Melloware Nov 19 '21 at 00:52
  • The client has agreed to buy some licenses, so i will be able to test with the latest v10 releases. – R.Quinlan Nov 22 '21 at 15:44
  • Upgraded to 10.0.7, but i have some broken code in my DataModel classes. SortMeta no longer has a getComponent() method. Is there documentation round this removal? I was getting a DynamicColumn from this before, DynamicColumn dc = (DynamicColumn) meta.getComponent(); but this is no longer. Is there another way? – R.Quinlan Nov 25 '21 at 10:55
  • I was using it to run some sql and pass in the index of the sorted columns to the ORDER BY clause of the sql – R.Quinlan Nov 25 '21 at 11:03

0 Answers0