users@javaserverfaces.java.net

RE: Re: I don't understand why I can't use a FacesMessage within a catch statement in a Backing Bean?

From: Todd Patrick <Todd.Patrick_at_dtn.com>
Date: Wed, 14 Mar 2007 15:40:58 -0500

No.

I am redisplaying the page.

Thanks,

--Todd

-----Original Message-----
From: Michael Youngstrom [mailto:youngm_at_gmail.com]
Sent: Wednesday, March 14, 2007 12:35 PM
To: users_at_javaserverfaces.dev.java.net
Subject: Re: I don't understand why I can't use a FacesMessage within a
catch statement in a Backing Bean?

Are you doing a redirect when rendering the new page by chance?

On 3/14/07, Todd Patrick <Todd.Patrick_at_dtn.com> wrote:
> JSF 1.2_04
> Sun Java System Application Server 9.0_01
>
> I don't understand why I can't use a FacesMessage within a catch
> statement in a Backing Bean?
>
> For example, in an event:
>
> public void doFreeFormSearch(ActionEvent event) {
> FacesContext facesContext = FacesContext.getCurrentInstance();
> FacesMessage message = new FacesMessage();
>
> ...
>
> try {
>
> ...
>
> } catch (MyException e) {
> message.setSeverity(FacesMessage.SEVERITY_ERROR);
> message.setSummary("No results found.");
>
> facesContext.addMessage(null, message);
> facesContext.renderResponse();
>
> logger.error("My Exception:", e);
>
>
> On my JSP page, I have:
>
> <h:messages/>
>
> When I catch MyException, the error message *is* written to my
> server.log file, but the h:messages component is never rendered?
>
> I step through this in Netbeans 5.5 and the FacesMessage is added to
> the FacesContext.
>
> How do I use FacesMessage correctly with a try/catch statement?
>
> (I've fought this for over a day now.)
>
> Thanks,
>
> --Todd
>
> -----------------------------------------
> NOTICE: This email message is for the sole use of the intended
> recipient(s) and may contain confidential and privileged information.
> Any unauthorized use, disclosure or distribution is prohibited. If you

> are not the intended recipient, please contact the sender by reply
> email and destroy all copies of the original message.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail:
> users-help_at_javaserverfaces.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net