来自<p:ajax>事件的触发通知栏

时间:2018-03-21 13:52:51

标签: primefaces jsf-2

我希望使用<p:ajax>在复选框点击时触发通知栏。通知栏将具有保存选项以将数据保存在数据库中。 <p:ajax>中的更新属性似乎不起作用。这是一项相当大的研究,但无法从解决方案中获得。我在这里错过了什么吗?我正在使用 JSF 2.1 + Primefaces 3.5 。任何帮助将非常感激。

xhtml页面

<p:column headerText="#{msgs.ref}" styleClass="menuHeader textAlignLeft">
    <p:notificationBar widgetVar="customSaveBar" position="top" styleClass="saveBar warningBar textAlignCenter" style="height: 25px;padding-top: 0; padding-bottom: 0;" effect="none" rendered="true">
          <h:outputText value="There are pending changes on the page." styleClass="warningText"/>
          <h:outputText value="&#160;"/>

          <p:commandLink action="#{abcDashboardBean.abcDTOValues}"
           onclick="skipPageRedirectWarning = true;showPleaseWait();"
           styleClass="warningText" id="saveFromBar"
           onsuccess="customSaveBar.hide()"
           oncomplete="placeRemoveIcon();"
           update="@form"
           process="@form"
           value="#{msgs.save}"/>
     </p:notificationBar>
     <p:selectBooleanCheckbox styleClass="margin_left_10" value="#{abcDto.refBl}"
                            rendered="#{!authorizationBean.userADMIN or !authorizationBean.userPM or !authorizationBean.userINDM}">
        <p:ajax event="click" partialSubmit="true" update="customSaveBar"></p:ajax>
    </p:selectBooleanCheckbox>

</p:column>

abcDashboardBean.java

public Map<Object, Boolean> getAbcDTOValues(){
    Map<Object, Boolean> map = new LinkedHashMap<Object, Boolean>();

    //fill the map with the items defaulted to unchecked
    for (AbcDTO abcDTO: abcList){
        map.put(abcDTO.getPpcCode(), Boolean.FALSE);
    }
    Abc abc1 = dataAccessEjbService.find(Abc.class, abc.getId());
    saveAbcRefChanges(map, abc1);
    return map;
}

public void saveAbcRefChanges(Map<Object, Boolean> map, Abc abc) {
    for (Map.Entry<Object, Boolean> entry : map.entrySet()) {
        if (entry.getValue().equals(true) && abc != null) {
            abc.setReferenceBl(true);
        } else {
            abc.setReferenceBl(false);
        }
    }
    dataAccessEjbService.update(abc);
}

AbcDTO.java

private boolean refBl;

// getters + setters 

0 个答案:

没有答案