![](/img/trans.png)
[英]a4j:included rich:dataTable negatively affects a4j:commandButton
[英]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.