Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:51:08+00:00 2026-05-26T07:51:08+00:00

I have what I suppose is a common problem: some managed bean has an

  • 0

I have what I suppose is a common problem: some managed bean has an action which adds some messages to the context:

FacesMessage fm = new FacesMessage("didn't work");
fm.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(null, fm);
return "some-outcome";

Then I map the outcome in faces-config.xml and configure it to

<navigation-case>
    <from-outcome>some-outcome</from-outcome>
    <to-view-id>/view.xhtml</to-view-id>
    <redirect/>
</navigation-case>

In view.xhtml I present the message:

<h:message globalsOnly="true" />

However, it does not work because the message is lost when the redirect is executed.

How would I solve it? I found this amazing post explaining how to do it using a PhaseListener but I believe this situation is too common to have to be solved this way. Am I wrong? Should I create the PhaseListener? Or is there some other, standard solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:51:08+00:00Added an answer on May 26, 2026 at 7:51 am

    Great answer from BalusC as usual!

    I just want to add, when i used his code to set the keepMessages property, it was not set for the session, but only for this request (despite what it says in the Javadocs).

    I put the following code in my header.xhtml
    <c:set target="#{flash}" property="keepMessages" value="true" />

    Now it works on every page, without me having to set it every time i need it in the backing bean.
    You need JSTL for this and dont forget to put the following in your xhtml header:
    xmlns:c="http://java.sun.com/jsp/jstl/core"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a common superclass (suppose it's Employee ), which has (amongst others) subclasses
suppose we have two numbers i want write program which print common bits subsequent
Suppose I have a model user , which has a uniqueness constraint on the
Suppose I have the following (rather common) model Client invokes web service request ->
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose each Person has a collection of favorite Books. So I have a table
Suppose I have two tables, Customer and Vendor. I want to have a common
Suppose that I have two data types Foo and Bar. Foo has fields x
Background: Suppose I have the following obviously-incorrect PHP: try{ $vtest = ''; print(array_pop($vtest)); }catch(Exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.