-
1. Re: FacesMessage added during render phase not displayed
niox.nikospara.yahoo.com Sep 21, 2009 1:57 PM (in response to sw_bpel)Hi,
Are the messages generated in an AJAX request? If so make sure the <h:messages /> is re-rendered.
-
2. Re: FacesMessage added during render phase not displayed
sw_bpel Sep 21, 2009 3:24 PM (in response to sw_bpel)No, i don't use a AJAX request here. It's only a
normal
XHTML page without AJAX components.
I have two cases here. The first case is, that on page load the table with entities is displayed. The second case is, that there are no entities, then i want to display a facesMessage, but it isn't displayed. So there is no redirect or anything else.page code:
<h:messages /> <a:outputPanel id="tablePanel" rendered="#{entityList != null and entityList.rowCount > 0}"> <h:dataTable id="entityTable" value="#{entityList}" var="en" rendered="#{entityList.rowCount > 0}"> ... </h:dataTable> </a:outputPanel>
the
<a:outputPanel />
Tag i only use here to check if the table should be displayed or not.
-
3. Re: FacesMessage added during render phase not displayed
niox.nikospara.yahoo.com Sep 21, 2009 4:34 PM (in response to sw_bpel)Have you tried to add the message according to the standard way:
FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN,"xxxx","yyyy") );
Does it display messages added this way?
-
4. Re: FacesMessage added during render phase not displayed
lucas84 Sep 21, 2009 5:18 PM (in response to sw_bpel)I guess that factory method is invoked during render response, after messages part has been rendered.
<h:messages/> ... ... <rich:dataTable value=#{list}> ... </rich>
Does yours xhtml looks like above?? When page is rendered, it first renders h:messages, at this point no messages were created so there is nothing to renderer. Later it renders rich:dataTable and starts resolving list, which finally calls your factory methods (which generates messages). But it's too late for adding messages as h:messages has been already rendered. You should look for log in console, something like this: message was queued but not displayed. If this is an issue, the solution is to call factory method before render response, ie. in page.xml using action execute.
-
5. Re: FacesMessage added during render phase not displayed
sw_bpel Sep 22, 2009 8:01 AM (in response to sw_bpel)Hey Nicos,
Have tried this also, but doesn't work.
I guess the suggested solution of Lukasz could probably help me. I'm going to try this and post the results. Thanks for your help!Greetz Stefan
-
6. Re: FacesMessage added during render phase not displayed
sw_bpel Sep 22, 2009 8:16 AM (in response to sw_bpel)Hello Lukasz,
yes that's it! I added this to my page.xml
<page view-id="/entity/list.xhtml"> <action execute="#{EntityListManager.initEntityList()}" /> ... </page>
and it works now. But is there no other way to publish FacesMessages during the render phase? Or can i turn the rendering of h:messages and rich:dataTable/h:dataTable? Or is there any programmatic solution for this? Can i call/do the rendering of m:messages myself e.g. in my factory method?
Anyway, so far thank you very much!
-
7. Re: FacesMessage added during render phase not displayed
vtyro Jun 27, 2011 6:38 AM (in response to sw_bpel)public static void test() {
FacesMessages.instance().addFromResourceBundle(WARN, "message.test");
refreshMessages();
}
private static void refreshMessages() {
// if render response phase try add messages to faces context
if(FacesContext.getCurrentInstance().getRenderResponse()) {
try {
// localization messages
FacesMessages.instance().afterPhase();
// Seam messages to standart JSF messages
FacesMessages.instance().beforeRenderResponse();
} catch (Throwable t) {
log.error(t, t);
}
}
}
Try this code...