NumberFormatException updating buttons inside facet header of p:columns

UI Components for JSF
Post Reply
HKM-CIA
Posts: 13
Joined: 02 Feb 2016, 15:52

28 Sep 2022, 08:00

Hi,
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>
The resulting button ids are "frmTest:dataTable:dailyValues:i:commandButton" with 'i' from 0 to number of columns - 1.

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();
	}
}
I downloaded and used your test project to verify the problem.

Greetings from Duisburg
Stephan Wenders
PrimeFaces 11.x Wildfly Application Server 21

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

28 Sep 2022, 13:36

You can open a GitHub issue ticket and attach your Primefaces Test reproducer.
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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 56 guests