In PrimeFaces, when you want to show an error Message you can:
- create in View a command Component that calls an action
- in 'update' attribute, you set the id of the p:message or p:growl component that will display the message
- in The backing Bean, in the action function you throw a message
As a result, the error message will be displayed in the redirect page, in the message component with the matching id
But what if :
- You want to display the message in another page, that doesn't contain the command component that called the action.
- The action can redirect to lots of different pages, depending on some Backing bean Logic.
- The action is not called from a command Component, at least not directly
I've thought of putting a p:message component with a specific id, and include it in every xhtml page. But this would not necessarily cover the 3rd scenario.
For example, there could be a function that checks the connection to another Web Service. A Connection error could be thrown from lots of different Actions.
- Or a session expiration
- Or a denial of permission
How would you manage this kind of generic error messages ?