This content has been marked as final.
Show 3 replies
-
1. Re: Displaying error messages on Logout 'Identity.instance().logout()'
michaelcourcy Aug 30, 2008 10:45 AM (in response to jskillings07)Did you try this ?
<page view-id="/logout.xhtml"> <navigation from-action="#{logoutBean.logout}"> <rule if-outcome="systemProblem"> <redirect view-id="/logoutWithExplanations.xhtml"> <message>#{messages.systemProblem}</message> </redirect> </rule> </navigation> </page>
I haven't try yet, let me know please.
-
2. Re: Displaying error messages on Logout 'Identity.instance().logout()'
michaelcourcy Aug 30, 2008 10:48 AM (in response to jskillings07)Uh this is not completly relevant
I meant :
<page view-id="/logout.xhtml"> <navigation from-action="#{logoutBean.logout}"> <rule if-outcome="systemProblem1"> <redirect view-id="/logoutWithExplanations.xhtml"> <message>#{messages.systemProblem1}</message> </redirect> </rule> <rule if-outcome="systemProblem2"> <redirect view-id="/logoutWithExplanations.xhtml"> <message>#{messages.systemProblem2}</message> </redirect> </rule> </navigation> </page>
Cheers
-
3. Re: Displaying error messages on Logout 'Identity.instance().logout()'
michaelcourcy Aug 30, 2008 11:12 PM (in response to jskillings07)I've been checking using message in a redirect doesn't work after logout, but using param does work.
What I did :
In pages.xml catch method call that could drive to an unexpected logout due to system error:
<page view-id="*"> .... <!-- catch method call that could potentially drive to a logout --> <navigation from-action="#{logoutBean.logout}"> <rule if-outcome="problem1"> <redirect view-id="/home.xhtml"> <param name="mess" value="systemProblem1"/> </redirect> </rule> <rule if-outcome="problem2"> <redirect view-id="/home.xhtml"> <param name="mess" value="systemProblem2"/> </redirect> </rule> </navigation> </page>
Dummy implementation of a method that drive to a logout
@Name("logoutBean") public class LogoutBean { @In Identity identity; public String logout(){ identity.logout(); return "problem1"; } }
Back in pages.xml add method execution in home.xhtml to catch the message in the incoming request.
<page view-id="/home.xhtml" action="#{messageParameters.addMessage}" />
Helper to retreive the message in the request
@Name("messageParameters") public class MessageParameters { @In FacesMessages facesMessages; @RequestParameter String mess; public void addMessage(){ if(mess!=null) facesMessages.addFromResourceBundle(mess); } }
But there's a better way as you cannot really recover from your system error is to throw an exception after the logout and then catch the exception with a redirect :
<exception class="com.mycompany.SystemException1"> <redirect view-id="/home.xhtml"> <param name="mess" value="systemProblem1"/> </redirect> </exception> <exception class="com.mycompany.SystemException2"> <redirect view-id="/home.xhtml"> <param name="mess" value="systemProblem2"/> </redirect> </exception>