p:menuitem onclick更新无法正常工作

时间:2015-07-04 07:42:47

标签: javascript jquery css jsf primefaces

我正在研究JSF / PrimeFaces但是当我使用来自主要面孔的menuitem时,那时我的表格面板无法自动工作。

<p:menuitem value="Hide Group" icon="ui-icon-close" styleClass="delete-group" onclick="pw_confirm_apply_end_date.show();return false" update="pnl_tbl_addr_group_mst" />

<p:confirmDialog widgetVar="pw_confirm_apply_end_date" message="Do you want to continue with applying end date?" style="width:300px">

  <p:commandButton id="btn_update_dlg" value="Apply End Date" icon="ui-icon-clock" process="@this" update=":form1:pnl_tbl_addr_group_mst,growl1" oncomplete="pw_confirm_apply_end_date.hide()" actionListener="#{addmst_grid.hideGroup}" />

  <p:commandButton value="Cancel" icon="ui-icon-close" onclick="pw_confirm_apply_end_date.hide();return false;" />
</p:confirmDialog>

当用户点击隐藏组按钮时,它会显示符合框,然后按应用后,组可以隐藏,但面板更新不起作用。

public void hideGroup(ActionEvent event) {
    FcadAddrGrpMst ent_AddrGrpMst = fcadAddrGrpMstFacade.find(selectedGroupMst.getAgmUniqueSrno());
    FacesContext context = FacesContext.getCurrentInstance();

    try {
        ent_AddrGrpMst.setEndDate(new Date());
        ent_AddrGrpMst.setUpdateby(new FhrdEmpmst(globalData.getUser_id()));
        fcadAddrGrpMstFacade.edit(ent_AddrGrpMst);

        try {
            setTbl_addr_group_mst();
            context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Hide Group", "Hide Group successfully"));
        } catch (Exception e) {
            logGenerator.generateLog(system_Properties.getSystemName(), Level.SEVERE, this.getClass().getName(), "hideGroup", null, e);
            context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Error in resetting components", "Hide Group successfully but error in resetting component(s) please refresh the page to view the changes"));
        }
    } catch (Exception e) {
        logGenerator.generateLog(system_Properties.getSystemName(), Level.SEVERE, this.getClass().getName(), "hideGroup", null, e);
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Some unexpected error occurred while saving record(s)"));
    }
}

1 个答案:

答案 0 :(得分:0)

onclick在客户端处理,但更新是在ajax事件之后完成的。为了使更新正常工作,你需要做一些ajax调用,比如p:menuitem action或actionListener调用服务器端方法。