How to show faces message in the redirected page

Keep the message in the flash scope. It’ll survive the redirect.

context.addMessage(clientId, message);
externalContext.getFlash().setKeepMessages(true);
return "users.xhtml?faces-redirect=true";

Note that older Mojarra versions have some peculiar Flash scope related bugs:

You’d best to upgrade to a minimum of Mojarra 2.1.27 / 2.2.5 in order to ensure that your application is not affected by this.

Leave a Comment