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

0 like 0 dislike
6 views
There is a page with a login form, after filling the correct pair login-password go to the main page of the website, and display an informational message that the authorization was successful. It should be noted that the transition to the main page redirect is happening in a query (how to redirect the welcome?faces-redirect=true or it 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 redirect shows an information message. At the same time, if the redirection is not done, but limited to one POST request, then an informational message is displayed.

Tried to activate
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true) 

but this mechanism helps to display the message only on the current page, even if we will return later, but on another page (another url) can't get the message.

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

Maybe somewhere, you need to specify the correct scope for or FacesMessage?

The project to spin on Glassfish 3, Java EE 6, JSF 2.
by | 6 views

1 Answer

0 like 0 dislike
to use a crutch
by

Related questions

0 like 0 dislike
2 answers
asked May 20, 2019 by SlandShow
0 like 0 dislike
1 answer
asked Apr 13, 2019 by alex_kag
0 like 0 dislike
1 answer
0 like 0 dislike
6 answers
110,608 questions
257,186 answers
0 comments
1,139 users