migrating applications from 6.x to 11.x we got a problem with the following use case.
We have a dataTable with buttons inside the facet header of a p:columns component.
Code: Select all
<h:form id="frmTest">
<p:dataTable id="dataTable" var="row" value="#{testView.rows}" rowKey="#{row.id}" selectionMode="multiple"
selection="#{testView.selectedRows}">
<p:ajax event="rowSelect" listener="#{testView.onRowSelect()}" update="frmTest:messages" />
<p:column style="width:40px">
<f:facet name="header">
<h:outputText value="id" />
<ui:fragment>
<br />
</ui:fragment>
<p:commandButton id="commandButtonId" value="OK" disabled="#{testView.buttonDisabled}" style="font-size:small;">
</p:commandButton>
</f:facet>
<h:outputText style="float:right;" value="#{row.id}" />
</p:column>
<p:columns id="dailyValues" columnIndexVar="columnIndex" value="#{testView.getDailyValues(row)}" var="dailyValue"
style="width:40px">
<f:facet name="header">
<h:outputText value="#{columnIndex+1}" />
<ui:fragment>
<br />
</ui:fragment>
<p:commandButton id="commandButton" value="OK" disabled="#{testView.buttonDisabled}" style="font-size:small;">
</p:commandButton>
</f:facet>
<h:outputText id="dailyValue" style="float:right;" value="#{dailyValue}" />
</p:columns>
</p:dataTable>
</form>
On rowSelect event the buttons are updated and get enabled or disabled.
With primefaces 6.2.30 everything works fine.
Using any version greater than 6.x, this leads to the following exception:
Caused by: java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'frmTest:dataTable:dailyValues:0:commandButton' For input string: "dailyValues"
However, updating a button inside the facet header of a p:column component works with any version.
Code: Select all
public class TestView implements Serializable {
.
public void onRowSelect() {
buttonsDisabled = !buttonsDisabled;
try {
// update for buttons in header of p:column works for all versions
PrimeFaces.current().ajax().update(columnButtonIds);
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "update buttons in header of p:column", "successful"));
} catch (Exception e) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,
"update buttons in header of p:column", e.getMessage()));
e.printStackTrace();
}
try {
// update for buttons in header of p:columns works only for versions < 7.x
PrimeFaces.current().ajax().update(dynamicColumnsButtonIds);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,
"update buttons in header of p:columns", "successful"));
} catch (Exception e) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,
"update buttons in header of p:columns", e.getMessage()));
e.printStackTrace();
}
}
Greetings from Duisburg
Stephan Wenders