如何在单击a4j:commandButton后显示rich:notify通知



单击a4j:commandButton后,我想显示一个包含来自我的模型的消息的rich:notify。

如何在点击我的命令按钮后触发此通知?

下面是我使用的代码:

* * DataTable * * * * * * *

<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" />

i set myModel。消息在deletecurcy()方法。

认为,

只需在命令按钮的动作中添加FacesMessageFacesContext,如下所示:

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);
}

相关内容

  • 没有找到相关文章

最新更新