I have one settings page on which I have submit button which executes bean's method when pressed. Now this method returns 'success' or 'failure' outcome. In either case request navigates to main.jsp page (navigation rule is specified in faces-config.xml). But my problem is that based on the outcome I want to show success or failure message in header of main.jsp.
I tried following things :
I tried to set requestparameter in my bean's method but it throws UnsupportedOperation exception.
I can set it in session e.g. session.set('message', message) and then retrieve message on main.jsp but but I have many such pages and user can navigate to any page any time. so if I retrieve session variable (message) on each main page it will return me last set message which is not proper.
I also tried to specify navigation rules something like this
1) Set a message in JSF's standard message system. You'll have to make sure you don't actually redirect the browser, but the message should show up on the main.jsp page (with the <h:messages/> tag)
2) Try facesContext.getExternalContext().getRequestMap().set("message", message); Then pull that in your page. Same deal with the redirect. However, that's essentially the same as #1, so you might as well use JSF's standard message facility.
If you want a redirect, I'm not sure. I don't know that you want to get into trying to pass stuff on the query string. I've had some growing pains with JSF myself. I'm personally a big fan of redirect. Mainly because the user can then get away with browser refresh. However, browser back and refresh are frowned upon in the JSF world, so I'm not sure it matters.
Now that I think about it, I'm going to make a post on that topic when I'm done with this.