JSF 2: How to display an informational message after a redirect?

Asked byemily b

There is a page with the authorization form, after correctly filling in the login-password pair, go to the main page of the site and display an informational message that the authorization was successful. It should be noted that the transition to the main page occurs by a redirect request (in which way the redirect welcome?faces-redirect=true or <redirect/> occurs does not matter).

The message is placed in FacesContext as follows:

FacesContext facesContext = FacesContext.getCurrentInstance();
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, message, null);
facesContext.addMessage(null, facesMessage);

The problem is that after the redirect <h:messages /> does not show an informational message. At the same time, if the redirect is not done, but confined to one POST request, an informational message is displayed.

Tried to activate

, but this mechanism helps to display a message, only on the current page, even if we return to it later, but on another page (at a different url-address), <h:messages /> cannot reach the message.

Accordingly, the question is - how to display an informational message after a redirect?

Maybe somewhere you need to specify the correct scope for <h:messages /> or FacesMessage?

The project is spinning on Glassfish 3, Java EE 6, JSF 2.


use link
Yes, I saw several similar hats, but there is a hope that JSF 2 has more elegant solutions. In any case, thank you for the link. - cansu g rler
However, this crutch works (under Glassfish 3, Java EE 6, JSF 2) - checked. - miriam wakerly
Found another resource with the same link. - travelgirlut
Opening the client's "dossier" during a telephone call :: Video cards. Which is better: GDDR5 and 128 bit or GDDR3 and 256 bit? :: Internet in the business center :: On which freelance stock exchange are the best copywriters and editors? :: What is missing in the modern CMS?
Leave Repply forJSF 2: How to display an informational message after a redirect?
Useful Links