【问题标题】:JSF 2 with PrimeFaces: Incell-Editing, no updated object in RowEditEvent parameter带有 PrimeFaces 的 JSF 2:Incell 编辑,RowEditEvent 参数中没有更新的对象
【发布时间】:2011-08-04 13:44:03
【问题描述】:

我在带有 Primefaces 2 的 Tomcat 6.0 上使用 Mojarra 2.0.3。

我有一个 dataTable 并希望使其可在单元格中编辑。一切正常,但我的带有参数“RowEditEvent 事件”的 rowEditListener 没有返回新对象。

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
}

托管 bean 在会话范围内。为什么监听器只接收到旧数据,而不是我写入incell-formular的数据?

希望你能帮助我。

来自德国的问候, 安迪

【问题讨论】:

    标签: java jsf datatable primefaces


    【解决方案1】:

    我发现了错误。

    tabledata 的 getter 每次从数据库中加载数据。

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

    此版本正在运行:

    私人名单 nutzerList;

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

    【讨论】:

    • 谢谢它的工作。你能解释为什么它会这样吗?你能形容“每次”吗?为什么tabledata每次都从数据库中加载数据?
    猜你喜欢
    • 2012-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-22
    • 2013-10-23
    • 1970-01-01
    相关资源
    最近更新 更多