2014-02-13 149 views
0

我已閱讀了許多關於類似問題的問題,但無法找到答案。我有這段代碼形式內:消息未在AJAX更新中顯示

<p:outputPanel id="articleInfo"> 
    <p:growl id="messages" autoUpdate="true"/> 
    <p:panel rendered="#{not empty myBB.selectedProduct}"> 
     <p:panel> 
      <h:outputText escape="false" value="#{myBB.content}"/> 
     </p:panel> 
     <p:commandButton value="Button" update=":mainForm:articleInfo"/>  
    </p:panel> 
</p:panel> 

當我點擊一個按鈕,在支持bean中生成新的內容和FacesMessage加入這樣的:

public String getContent(){ 
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, title, detail)); 
    return "something"; 
} 

阿賈克斯更新很好,因爲我看到新內容,addMessage也被稱爲,但我看不到消息。我試過p:messages而不是咆哮,加入for="mainForm:articleInfo"和調用addMessage用「的MainForm:articleInfo」(我檢查了它的在視圖中正確的ID

我仍然無法找到一個原因

+0

p:commandButton具有更新屬性本身,爲什麼你使用ajax事件。 – Makky

+0

它實際上是從'''p:tree''複製的,但我想保持代碼最小。如果我把它放在commandButton更新屬性上,結果是一樣的。我已經改變了它,所以它並沒有讓人困惑。 – NeplatnyUdaj

+0

我沒有在cmomand按鈕上看到actionListener或動作? – Makky

回答