question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Datatable: Composite Component + p:rowExpansion + Mojarra 2.3

See original GitHub issue

Describe the defect We are using p:dataTable inside a composite component, called mc:dataTable. The p:dataTable inside mc:dataTable uses the same ID as the naming container. (e.g. id=“#{cc.id}”) This is the critical information!

When mc:dataTable contains a p:rowExpansion, AND that p:rowExpansion contains another mc:dataTable, the “var” entity of the inside mc:dataTable is null.

The “var” of the inside mc:dataTable is null for Mojarra23. Mojarra22 works fine.

Background: We are currently trying to migrate from PrimeFaces 8 => 11 and from WildFly 24 => 26. (I could reproduce the problem with PF8, too. So the problem is with WildFly 26)

Reproducer Clone repository https://github.com/Exandra/primefaces-test.git in order to reproduce the problem.

Environment:

  • PF Version: 11.0.0
  • PF Theme: Saga
  • JSF + version: Mojarra22 works, Mojarra 23 doesn’t work
  • Affected browsers: ALL

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/Exandra/primefaces-test.git
  2. cd primefaces-test
  3. mvn clean jetty:run -Pmojarra23
  4. Open “http://localhost:8080/primefaces-test/
  5. Expand an arbitrary row. E.g. Alfa_Romeo. The exanded table provides Alfa_Romeo => ERROR.
  6. Quit jetty ctrl + c
  7. mvn clean jetty:run -Pmojarra22
  8. Repeat steps 3 and 4. The result will be something like Alfa_Romeo => fd077c

Expected behavior The composite component should work inside inside a p:rowExpansion with id=“#{cc.id}”, independently from the JSF implementation.

The problem is definetly the id of the p:dataTable inside the composite component. If I change e.g. the id=“dataTable_#{cc.id}” everything works fine.

I don’t know, whether we’re using a bug of the JSF implementation until now. But the problem is, that we need to change a lot of pages, to change the ID of the inner dataTable. 😦

Are you able to “fix” this issue on the primefaces side?

Usage of mc:dataTable

        <mc:dataTable id="foo"
                      value="#{testView.cars}"
                      rowKey="#{car.brand}"
                      var="car">

            <p:column width="50">
                <p:rowToggler/>
            </p:column>

            <p:column headerText="Brand">
                #{car.brand}
            </p:column>

            <p:rowExpansion>
                <mc:dataTable id="bar" var="plate" value="#{car.licensePlates}">
                    <p:column>
                        #{car.brand} => #{not empty plate ? plate : 'ERROR'}
                    </p:column>
                </mc:dataTable>
            </p:rowExpansion>
        </mc:dataTable>

mc:dataTable

<composite:implementation>
    <f:event type="postAddToView" listener="#{cc.init}"/>

    <p:dataTable
            id="#{cc.id}"
            binding="#{cc.datatable}"
            value="#{cc.attrs.value}"
            rowKey="#{cc.attrs.rowKey}">
        <composite:insertChildren/>
    </p:dataTable>
</composite:implementation>

mc:dataTable backing component

@FacesComponent(value = "org.primefaces.test.DataTable")
public class DataTable extends UINamingContainer {

	private org.primefaces.component.datatable.DataTable datatable;

	public void init() {
		String idAttribute = (String) getAttributes().get("id");
		String idDatatable = datatable.getId();
		System.out.format("idAttribute=%s, idDatatable=%s\n", idAttribute, idDatatable);
		datatable.setVar((String) getAttributes().get("var"));
	}

	public org.primefaces.component.datatable.DataTable getDatatable() {
		return datatable;
	}

	public void setDatatable(org.primefaces.component.datatable.DataTable datatable) {
		this.datatable = datatable;
	}
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Exandracommented, Mar 17, 2022

Problem has been introduced with Mojarra 2.3.17. 2.3.16 is working fine. The only commits I found in 2.3.17, which are related to IDs, are regarding a new ID cache, which might be the cause and which already produced other/same problems. I found an already existing issue here: https://github.com/eclipse-ee4j/mojarra/issues/5065

0reactions
mellowarecommented, Mar 17, 2022

Also make sure to attach your PrimeFaces Test reproducer in the Mojarra issue so they can see and debug the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DataTable as Composite Component with LazyDataModel Not ...
I am facing problems while trying to use primefaces datatable as composite component. Below are my code snippet: commonDataTable.xhtml:
Read more >
Datatable as composite component - Prime Community Forum
Hi guys, im trying to use primefaces datatable as composite component but till now i have no sucess. Im using this fixed issue...
Read more >
DataTable: rows attribute get overriden with default value #6132
We have a composite component around a dataTable. ... JSF + version: Mojarra 2.3.9; Affected browsers: does not matter. To Reproduce
Read more >
primefaces - issue #3840 - Google Code
Create a JSF 2.0 composite component with a <p:dataTable> inside 2. Add an attribute in this component containing a LazyDataModel instance 3 ...
Read more >
Composite component with multiple input fields
Use Composite Components if you want to create a single and reuseable custom UIComponent with a single responsibility using pure XML.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found