开发者

JSF 2 with PrimeFaces: Incell-Editing, no updated object in RowEditEvent parameter

开发者 https://www.devze.com 2023-03-26 01:33 出处:网络
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\

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.

public void onEditRow(RowEditEvent event) {
    Nutzer nutzer = (Nutzer) event.getObject(); // Get object f开发者_如何学运维rom 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
}

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


I found the mistake.

The getter for the tabledata loaded the data everytime out of the database.

private List<Nutzer> nutzerList;

public List<Nutzer> getNutzerList() {
    nutzerList = nutzerManager.getNutzer();
    return this.nutzerList;
}

This version is working:

private List nutzerList;

public List<Nutzer> getNutzerList() {
    if(nutzerList == null)
        nutzerList = nutzerManager.getNutzer();
    return this.nutzerList;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消