0

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

单击我的 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。

问候,

4

1 回答 1

0

只需在命令按钮的操作中添加一个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);
}
于 2013-04-03T12:40:50.240 回答