簡體   English   中英

單擊a4j:commandButton后如何顯示rich:notify通知?

[英]How to display rich:notify notification after clicking a a4j:commandButton?

單擊a4j:commandButton后,我想顯示一個rich:notify,其中包含來自我的Model的消息?

單擊我的commandButton后如何觸發此通知?

這是我使用的代碼:

** 數據表 ** * ****

<rich:dataTable id="currencyDataTable"  value="#{s2MCurrencyModel.getAllS2MCurrency()}"
                var="currency" border="1">

                <rich:column>
                    <f:facet name="header">Task ID</f:facet>
                    <h:outputText value="#{currency.taskId}" />
                </rich:column>
........
                <rich:column>
                    <h:form>

                        <a4j:commandButton value="Delete"
                            render="currencyDeleteInfo"
                            oncomplete="#{rich:component('currencyDelete')}.show()"
                            disabled="#{!currency.status.equals('I')}">
                            <f:setPropertyActionListener
                                target="#{s2MCurrencyModel.selectedCurrency}"
                                value="#{currency}" />
                        </a4j:commandButton>
                    </h:form>
                </rich:column>
            </rich:dataTable>

<!-- =============   DELETE BOX  =============== -->
    <rich:popupPanel id="currencyDelete">
        <f:facet name="header">currency delete confirmation</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#"
                onclick="#{rich:component('currencyDelete')}.hide(); return false;">
                X
             </h:outputLink>
        </f:facet>
        <h:form>
            <h:panelGrid id="currencyDeleteInfo">
                Do you want really to delete currency identified by: 
                <h:outputText
                    value="#{s2MCurrencyModel.selectedCurrency.currencyCode}" />

                <h:panelGroup>
                <a4j:commandButton value="Delete"
                    oncomplete="#{rich:component('currencyDelete')}.hide();return false"
                    action="#{s2mCurrencyCtrl.deleteCurrency()}"
                    render="currencyDataTable"
                    />
                    **<rich:notify detail="#{s2MCurrencyModel.message}" stayTime="5000" summary="Notification" showShadow="true" />**
                <h:button value="Cancel" onclick="#{rich:component('currencyDelete')}.hide(); return false;"/>
                </h:panelGroup>
            </h:panelGrid>
        </h:form>
    </rich:popupPanel>

                    render="currencyDataTable"
                    />
                    <rich:notify detail="#{myModel.message}" stayTime="5000" />

我在deleteCurrency()方法中設置了myModel.message。

問候,

只需在命令按鈕的操作中將FacesMessage添加到FacesContext即可,如下所示:

public void deleteCurrency(){
//your other operations
FacesContext ctx = this.getCurrentInstance();
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Detail","Summary"); //FacesMessage has other info levels
ctx.addMessage(null,msg);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM