2016-10-26 36 views
0

我有一個PrimeFaces <p:commandButton update=":messages"其發送的形式後不顯示p:messages,但如果使用update="@all"代替它更新p:messages,我可以看到顯示的消息。primefaces號碼:的commandButton更新屬性未能更新號碼:消息組件

我試過很多其他組合,如update="messages",update="NewRegistryForm:messages",update="@form :messages",render=":messages" ......但沒有別的似乎工作。任何想法爲什麼這可能會發生?

RegistryInputNewBean.processRequest我簡單地更新信息組件是這樣的:

FacesContext.getCurrentInstance().addMessage(
    null, 
    new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "error_processing_request") 
); 

mytemplate.xhtml,含p:messages,是這樣的:

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:p="http://primefaces.org/ui" 
    lang="en" 
> 
    <f:view contentType="text/html" encoding="UTF-8" locale="en"> 
     <h:head> 
      <title>test</title> 
     </h:head> 
     <h:body id="pageBody"> 
      <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" showSummary="false"/> 
      <ui:insert name="content" /> 
     </h:body> 
    </f:view> 
</html> 

myform.xhtml是這樣的:

<!DOCTYPE html> 
<html 
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:p="http://primefaces.org/ui" 
> 
<ui:define name="content"> 
<ui:composition template="mytemplate.xhtml"> 
     <h:form id="NewRegistryForm"> 
       <p:commandButton 
        id="sendButton" 
        type="submit" 
        action="#{registryInputNewBean.processRequest}" 
        update="@all" 
        style="display:none" /> 
     </h:form> 
</ui:composition> 
</ui:define> 
</html> 

回答

0

p:messages不在表單內,這就是爲什麼按鈕不會單獨更新組件的原因,僅當您將@all更新爲頁面中的所有組件時纔會更新該組件。

如果你把包含p:message內的另一種形式,你將能夠與update="fooForm:fooMessages"

0

你可以在豆更新

RequestContext rc = RequestContext.getCurrentInstance(); 
rc.update("id"); 
+0

更新組件是你可以,但會導致不同於在'p:commandButton'上使用'update'的行爲? –

相關問題