Datatable: Composite Component + p:rowExpansion + Mojarra 2.3
See original GitHub issueDescribe 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:
- git clone https://github.com/Exandra/primefaces-test.git
- cd primefaces-test
- mvn clean jetty:run -Pmojarra23
- Open “http://localhost:8080/primefaces-test/”
- Expand an arbitrary row. E.g. Alfa_Romeo. The exanded table provides Alfa_Romeo => ERROR.
- Quit jetty ctrl + c
- mvn clean jetty:run -Pmojarra22
- 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:
- Created 2 years ago
- Comments:7 (5 by maintainers)
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
Also make sure to attach your PrimeFaces Test reproducer in the Mojarra issue so they can see and debug the issue.