I am using custom ajax-called javacode that does some processing on the server. In this process various errors can occure that I add to the FacesContext via ad开发者_开发问答dMessage(). 
I want to display these messages in the same <rich:messages>-tag that I use for my validation errors. 
Do you know a way to display these messages in the <rich:messages>-tag after the ajax-request completed?
My initial idea was adding 
<a4j:jsFunction name="richDisplayError" reRender="messages" />
to the markup and calling richDisplayError when the request completed, but it seems the messages panel is rerendered empty. 
<rich:messages> has ajaxRenderedset to true by default. So the problem lies elsewhere. Perhaps:
- you are redirecting, instead of forwarding, and the messages are lost
- you aren't actually adding the messages (check with debug)
- you are having different/lacking views/subviews
For example, in your page:
    <a4j:commandButton value="Action"
           limitToList="true" 
           action="#{mybean.action}"
           reRender="mymessages">
    </a4j:commandButton>
    <a4j:outputPanel ajaxRendered="true">
       <h:messages id="mymessages"  />
    </a4j:outputPanel>
then in you bean:
public void action(){                         
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("hello world")); 
}    
You need 3 things :
1st : declare your error message, in the "\resources\bundle\errorMessages.properties" file, like this :
errorMsgToDisplay.errName = Your Error Message Here
2nd : declare your BUNDLE variable in the class code :
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("/bundle/errorMessages");
3rd : Display the message (after an condition for example )
if  ( condition ) {
FacesContext.getCurrentInstance().addMessage("", new FacesMessage(FacesMessage.SEVERITY_ERROR, 
BUNDLE.getString("errorMsgToDisplay.errName"),
BUNDLE.getString("errorMsgToDisplay.errName")));
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论