【问题标题】:Issue with p:ajax event colReorderp:ajax 事件 colReorder 的问题
【发布时间】:2017-09-29 13:49:22
【问题描述】:

p:dataTable 中,我有一些 ajax 事件,当我编辑某些内容时会显示 FacesMessages

<p:ajax event="cellEdit" listener="#{userRegistrationController.cellEditAction}"
                            update=":currentUserForm:currentUsersFormMessages"/>
<p:ajax event="colResize" listener="#{userRegistrationController.colResizeAction}"
                            update=":currentUserForm:currentUsersFormMessages"/>
<p:ajax event="colReorder"  listener="#{userRegistrationController.colReorderAction}"
                            update=":currentUserForm:currentUsersFormMessages"/>

唯一不起作用的是“colReorder”,当我调用方法时,我有 javax.el.MethodNotFoundException: Method not found: com.mycompany.primeautosales.jsf.UserRegistrationController@476d042d.colReorderAction( javax.faces.event.AjaxBehaviorEvent) 。 这是colResizeActioncolReorderAction 的方法,我不明白为什么一个有效而另一个无效。

public void colResizeAction(ColumnResizeEvent event){
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
            "the width of column "+event.getColumn()+" is now "+event.getWidth()
    ));
}

public void colReorderAction(ReorderEvent event){
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
            "reordered "+event.getComponent().toString()));
}

ReorderEvent 类有什么问题吗?

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    尝试将 bean Action 参数 ty 更改为如下代码所示的操作行为

    public void onReorder(AjaxBehaviorEvent event) {
     DataTable dataTable = (DataTable) event.getComponent();
     List<UIColumn> columns = dataTable.getColumns();
    
     //build new column order to store  
     for(UIColumn : column columns)
     {
      //read column names
     }
    //store list to db
    }
    

    供参考Click here

    【讨论】:

      【解决方案2】:

      问题是ajax事件“colReorder”不支持监听参数org.primefaces.event.ReorderEvent。这就是为什么你有这个错误!正如上面提到的@Araf,AjaxBehaviorEvent 事件是由 colReorder 事件支持的。

      【讨论】:

        猜你喜欢
        • 2014-07-08
        • 1970-01-01
        • 2014-12-26
        • 2019-10-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-19
        • 1970-01-01
        • 2011-05-20
        相关资源
        最近更新 更多