myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Madhav Bhargava <Madhav_Bharg...@infosys.com>
Subject RE: Displaying messages over the content - generated by the content?
Date Fri, 12 Dec 2008 10:45:28 GMT
Madhav Bhargava schrieb:
> Felix.Becker@t-systems.com schrieb:
>   
>> Hi,
>>
>> I've got a JSF page divided in 2 parts - the status message area and
>> the content area. The content area is positioned under the status
>> message area. In the status area all messages for the user should be
>> shown - for example success messages, error messages and exceptions.
>> In my content area I've got a <tr:dataTable
>> value="#{myBean.values}"..>. When the method getValues() of myBean
>> throws an exception, I'm catching this exception. I want to display
>> this exception in the status message area - but this does not work -
>> apparently because the status area is already rendered when the
>> content el-methods are called. Is there any solution for this problem?
>> Is it possible to render the status area at last?
>>
>>     
> One quick solution can be to call a javascript function on onload. This function can
do an ajax submit and re-render the status area of your JSP. If there are any error messages
then that will displayed else nothing will be displayed. 
> If you want more control then do not add the FacesMessage to the FacesContext, instead
handle it yourself.
>   

Simon wrote:

>Will re-rendering messages using a separate ajax request work?

>FacesMessage objects are attached to the FacesContext, not the view. And
>a FacesContext is a request-scoped object. So AFAIK, a second request
>will always see an empty messages list...

>Regards,
>Simon

Yes you are right. What I was talking about was a simple hack. For specific messages like
the ones that are generated during the render response you do not add it to the FacesContext.
Instead you maintain them into a separate list whose scope is say conversation scope rather
than a request scope. When the page is rendered, onbody is called which will see if there
are any messages. Component like t:messages will inherently read from FacesContext. You can
create your own component extending say t:messages and read from a different source as well.

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Mime
View raw message