rowEditor with MyFaces

UI Components for JSF
Post Reply
Keith Wong
Posts: 11
Joined: 04 Oct 2011, 09:33

04 Oct 2011, 12:28

Hi,

I have a problem when using rowEditor with Myfaces 2. Here is the page fragment:

Code: Select all

<p:dataTable var="customer" value="#{customers}">
	<p:column headerText="First Name">
		<p:cellEditor>
			<f:facet name="output">
				<h:outputText value="#{customer.firstName}"/>
			</f:facet>
			<f:facet name="input">
				<p:inputText value="#{customer.firstName}" required="true"/>
			</f:facet>
		</p:cellEditor>
	</p:column>

	<p:column headerText="Options">
		<p:rowEditor/>
	</p:column>

</p:dataTable>
Steps to reproduce the problem:
  1. Assume #{customers} have 3 items: [Peter, Paul, Mary]. Click the second Row Edit button, i.e. Paul
  2. Change 'Paul' to 'David' in the firstName field and click the Row Save button
It is observed that the 'Paul' is not changed in both the screen and the model. Instead, the screen shows [Peter, Paul, Mary] and the model becomes [Mary, Paul, Mary]. It seems copies the last row to the first row and ignores the editing row.

After investigation, the cause could be in the request parameter javax.faces.source generated by the doRowEditRequest function in datatable.js.

Code: Select all

PrimeFaces.widget.DataTable.prototype.doRowEditRequest = function(element, action) {
	var row = $(element).parents('tr').eq(0),
	options = {
		source: this.id,
		update: this.id,
		formId: this.cfg.formId
	},
	...
From the above fragment, the source of the save action is the id of the table. For some reason, MyFaces 2 will put the source into the execution list and thus mess up the model update in the table. So, I suggest to use the id of the rowEditor instead of the table as the source of the save action to solve the problem. See the last line of the following:

Code: Select all

if(action === 'save') {
	//Only process cell editors of current row
	var editorsToProcess = new Array();

	row.find('span.ui-cell-editor').each(function() {
		editorsToProcess.push($(this).attr('id'));
	});

	options.process = editorsToProcess.join(' ');
	options.source = rowEditorId;
}
Primefaces 3.4.2
MyFaces 2.1.9
WebSphere 8.5

Rainer
Posts: 8
Joined: 21 Mar 2011, 17:28

20 Oct 2011, 16:48

Hi,
I encountered the same problem using primefaces 3.0.3M and myfaces 2.1.3. It was ok with the Moraja implementation though.
(For anyone interested try the datatable incell editing example from the showcase). I changed the line in datatable.js as you suggested. Many thanks for the advice.

Will this be fixed in the next release?

Rainer
Primefaces 3.0.M3
MyFaces 2.1.3
GAE

javito
Posts: 1
Joined: 16 Nov 2011, 13:40

16 Nov 2011, 13:42

This solution don't work in my project... :cry:

christoph
Posts: 1
Joined: 12 Jan 2012, 21:36

12 Jan 2012, 21:40

Same here with PrimeFaces 3.0.RC2 and MyFaces 2.1.3 but works completely fine with Mojarra 2.1.2 so you can try to replace MyFaces with Mojarra:

<jsf.version>2.1.2</jsf.version>

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
</dependency>

BR
Chris

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests