p:dataTable doesn't display each p:selectManyCheckbox selected

UI Components for JSF
NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

22 Aug 2019, 22:00

Passed on the demo example of https://www.primefaces.org/showcase/ui/ ... asic.xhtml and I can show the complete example as primefaces-test-master and run as mvn clean jetty:run-exploded

I've created a displays using 'p:selectManyCheckbox ' to show all my Year, Brand, Colour, Price & Sold' as:

Code: Select all

<p:selectManyCheckbox id="carColumns" value="#{carService.selectedItems}">
            <f:selectItem itemLabel="Year" itemValue="Year"/>
            <f:selectItem itemLabel="Brand" itemValue="Brand"/>
            <f:selectItem itemLabel="Colour" itemValue="Colour"/>
            <f:selectItem itemLabel="Price" itemValue="Price"/>
            <f:selectItem itemLabel="Sold" itemValue="Sold"/>
            <p:ajax listener="#{carService.selectedItemsChanged}" update="formCars:tblCars"/>
 </p:selectManyCheckbox>
It then displays the p:dataTable and each p:column of the 'car' plus the others:

Code: Select all

<p:dataTable id="tblCars" var="car" value="#{dtBasicView.cars}" paginator="true"
                     rows="100"
                     multiViewState="true"
                     paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                     rowsPerPageTemplate="5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100"
                     resizableColumns="true"
                     draggableColumns="true"
                     scrollWidth="100%">

            <f:facet name="header">
                <p:commandButton id="columnTogglerCars" type="button" value="Columns" style="float:right"
                                 icon="pi pi-align-justify"/>
                <p:columnToggler datasource="tblCars" trigger="columnTogglerCars"/>
            </f:facet>

            <p:column headerText="Id" rendered="true">
                <h:outputText value="#{car.id}"/>
            </p:column>

            <p:column headerText="Year" sortBy="#{car.year}" rendered="#{carService.yearColumnRendered}">
                <h:outputText value="#{car.year}"/>
            </p:column>

            <p:column headerText="Brand" sortBy="#{car.brand}" rendered="#{carService.brandColumnRendered}">
                <h:outputText value="#{car.brand}"/>
            </p:column>

            <p:column headerText="Colour" sortBy="#{car.colour}" rendered="#{carService.colourColumnRendered}">
                <h:outputText value="#{car.colour}"/>
            </p:column>

            <p:column headerText="Price" sortBy="#{car.price}" rendered="#{carService.priceColumnRendered}">
                <h:outputText value="#{car.price}"/>
            </p:column>

            <p:column headerText="Sold" sortBy="#{car.sold}" rendered="#{carService.soldColumnRendered}">
                <h:outputText value="#{car.sold}"/>
            </p:column>
</p:dataTable>
If I then alter the orders (up or down) displayed of p:column headerText on the selected items of p:selectManyCheckbox then sometimes will not actually displayed each of the 'Year, Brand, Colour, Price & Sold' in dataTable.

Am I doing something wrong with p:selectManyCheckbox and p:dataTable ?
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

28 Aug 2019, 15:51

PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

28 Aug 2019, 16:25

Can you put your primefaces-test-master.zip (without /target folder) somewhere i can download?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

28 Aug 2019, 17:54

PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

28 Aug 2019, 19:07

Maybe I don't understand what the problem is but your example works fine for me? I can click items in the SelectMany and your columns hide or display based on what I have selected?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

28 Aug 2019, 21:37

The 'SelectMany' values are not always shown in 'dataTable' with 'column'.

See the three example in: https://stackoverflow.com/questions/576 ... x-selected

In 1) Hows all five images 'Year, Brand, Colour, Price & Sold'. (2) Show two pages 'Year, Brand' (3) Selects "Year, Brand, Colour but it only shows '"Year, Brand', though selected (Colour)
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

28 Aug 2019, 22:15

Did you try vince suggestion: https://stackoverflow.com/a/57699024/502366

That just worked for me.

Wrap the datatable in panel

Code: Select all

<p:panel id="panel-update">
And change AJAX to...

Code: Select all

<p:ajax listener="#{carService.selectedItemsChanged}" update="panel-update"/>
Doing this I cannot reproduce your issue.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

28 Aug 2019, 22:36

I have tried 'vincenzopalazzo' but didn't help.

I think it is caused by:

Code: Select all

sortBy="#{car.xxxxx}"
When the 'sortBy' is changed and removed from:

Code: Select all

<p:selectManyCheckbox id="carColumns" value="#{carService.selectedItems}">
            <f:selectItem itemLabel="Year" itemValue="Year"/>
            <f:selectItem itemLabel="Brand" itemValue="Brand"/>
            <f:selectItem itemLabel="Colour" itemValue="Colour"/>
            <f:selectItem itemLabel="Price" itemValue="Price"/>
            <f:selectItem itemLabel="Sold" itemValue="Sold"/>
            <p:ajax listener="#{carService.selectedItemsChanged}" update="formCars:tblCars"/>
 </p:selectManyCheckbox>
So if I change which is selected in 'f:selectItem' it will be not be displayed on 'p:dataTable' etc.

If I re-select 'f:selectItem' it won't display it again in 'f:selectItem', even though it had been selected in 'f:selectItem'

My displays in https://stackoverflow.com/questions/576 ... x-selected

Shows in:

(3) Selects "Year, Brand, Colour but it only shows '"Year, Brand', though selected (Colour)
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

29 Aug 2019, 09:56


NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

04 Sep 2019, 20:44

I'm now convinced the is a bug with 'sortBy' and 'selectItem'.

Most of the solutions offered are rather "sketchy" at the best.

Where in 'primefaces/primefaces' do I point my 'primefaces-test'?

Code: Select all

 <h:form id="formCars">
        <p:selectManyCheckbox id="carColumns" value="#{carService.selectedItems}">
            <f:selectItem itemLabel="Id" itemValue="Id"/>
            <f:selectItem itemLabel="Year" itemValue="Year"/>
            <f:selectItem itemLabel="Brand" itemValue="Brand"/>
            <f:selectItem itemLabel="Colour" itemValue="Colour"/>
            <f:selectItem itemLabel="Price" itemValue="Price"/>
            <f:selectItem itemLabel="Sold" itemValue="Sold"/>
            <p:ajax listener="#{carService.selectedItemsChanged}" update="formCars:tblCars"/>
        </p:selectManyCheckbox>

        <p:dataTable id="tblCars" var="car" value="#{dtBasicView.cars}" paginator="true"
                     rows="100"
                     multiViewState="true"
                     paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                     rowsPerPageTemplate="5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,96,100"
                     resizableColumns="true"
                     draggableColumns="true"
                     scrollWidth="100%">

            <f:facet name="header">
                <p:commandButton id="columnTogglerCars" type="button" value="Columns" style="float:right"
                                 icon="pi pi-align-justify"/>
                <p:columnToggler datasource="tblCars" trigger="columnTogglerCars"/>
            </f:facet>

            <p:column headerText="Id" rendered="#{carService.idColumnRendered}" sortBy="#{car.id}">
                <h:outputText value="#{car.id}"/>
            </p:column>

            <p:column headerText="Year" rendered="#{carService.yearColumnRendered}" sortBy="#{car.year}">
                <h:outputText value="#{car.year}"/>
            </p:column>

            <p:column headerText="Brand" rendered="#{carService.brandColumnRendered}" sortBy="#{car.brand}">
                <h:outputText value="#{car.brand}"/>
            </p:column>

            <p:column headerText="Colour" rendered="#{carService.colourColumnRendered}" sortBy="#{car.colour}">
                <h:outputText value="#{car.colour}"/>
            </p:column>

            <p:column headerText="Price" rendered="#{carService.priceColumnRendered}" sortBy="#{car.price}">
                <h:outputText value="#{car.price}"/>
            </p:column>

            <p:column headerText="Sold" rendered="#{carService.soldColumnRendered}" sortBy="#{car.sold}">
                <h:outputText value="#{car.sold}"/>
            </p:column>
        </p:dataTable>
    </h:form>
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 42 guests