Incell-Editing, no updated object in RowEditEvent parameter

UI Components for JSF
Post Reply
Organized
Posts: 7
Joined: 05 Aug 2011, 09:10

05 Aug 2011, 09:14

Hi

I'm using Mojarra 2.0.3 on Tomcat 6.0 with Primefaces 2.

I got a dataTable and want to make it incell-editable. Everything works fine, but my rowEditListener with the parameter "RowEditEvent event" returns no new object.

Code: Select all

public void onEditRow(RowEditEvent event) {
    Nutzer nutzer = (Nutzer) event.getObject(); // Get object from event
    System.out.println(nutzer.toString()); // This prints the OLD data,
                                           // not the data I wrote into the form
    nutzerManager.editNutzer(nutzer);      // Write into the database
}

Code: Select all

<p:dataTable var="n" value="#{manageNutzer.nutzerList}" rowEditListener="#{manageNutzer.onEditRow}">
	<p:column headerText="#{lang.surnameLabel}">
		<p:cellEditor>
			<f:facet name="output">
				<h:outputText value="#{n.vname}" />
			</f:facet>
			<f:facet name="input">
				<p:inputText value="#{n.vname}" />
			</f:facet>
		</p:cellEditor>
	</p:column>

	[...]

	<p:column headerText="#{lang.optionsLabel}">
		<p:rowEditor />
	</p:column>
</p:dataTable>
The managed bean is in session scope. Why does the listener only receive the old data, not the data I wrote into the incell-formular?

Hope, you can help me.

Greets from germany, Andy

Organized
Posts: 7
Joined: 05 Aug 2011, 09:10

05 Aug 2011, 09:35

Hi dudes,

got it working!

The mistake was following:
Everytime, the getter for the List was called, I loaded the data from the database:

Code: Select all

private List<Nutzer> nutzerList;

public List<Nutzer> getNutzerList() {
	nutzerList = nutzerManager.getNutzer();
	return this.nutzerList;
}
I had to check, if nutzerList is null, if so, I load the data into it, if not, I do nothing:

Code: Select all

private List<Nutzer> nutzerList;
	
public List<Nutzer> getNutzerList() {
	if(nutzerList == null)
		nutzerList = nutzerManager.getNutzer();
	return this.nutzerList;
}
This is all!

Greets,
Andy

A little question by the way: Is it possible to format the <rowEditor />-Tag? Change the images?

aferper9
Posts: 6
Joined: 17 Oct 2011, 14:02

17 Oct 2011, 14:42

Really really thanks!!!


I was looking for this solution many hours!!

As you, changes weren't save on database. After do this change in the List's getter, works fine.

Thanks a lot

---------
If you want change the icon, you can do it using css

Code: Select all

<p:column headerText="#{msg.edit}" styleClass="ui-editable-column-options" >  
			            <p:rowEditor/>
	  </p:column> 
and in the css file...

Code: Select all

.ui-editable-column-options .ui-icon-pencil{
	background-image: url(./images/pencil.png)
}

pfdev
Posts: 5
Joined: 06 Mar 2012, 17:11

16 Mar 2012, 07:40

Thanks a lot! your solution worked for me too :)
****************************
Using primefaces-3.2.jar with JSF(Mojarra) 2.1.7
****************************

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests