-
1. Re: Problems with redirect after catching Exception
lightguard Apr 28, 2011 4:03 PM (in response to stormqueen)Could you please inject the FacesContext (or getCurrent) and tell us which phase you're in when you hit the catch handler?
-
2. Re: Problems with redirect after catching Exception
stormqueen Apr 29, 2011 2:12 AM (in response to stormqueen)It just happens when I'm in the RENDER_RESPONE Phase.
When I'm forcing the error in another Phase (e.g. with a h:comandButton in INVOKE_APPLICATION) it works fine. -
3. Re: Problems with redirect after catching Exception
lightguard May 20, 2011 12:35 AM (in response to stormqueen)This may be a JSF issue as it seems like data has already been written to the response, not sure if there's a great way of doing this if an error occurs during the RENDER_RESPONSE phase. We may need a more advanced JSF guru to comment. You can also watch http://seamframework.org/Community/SeamCatchViewExpiredExceptionAndRedirect as that is a similar issue.
-
4. Re: Problems with redirect after catching Exception
stormqueen May 20, 2011 2:20 AM (in response to stormqueen)Ok, thanks for your effort!
-
5. Re: Problems with redirect after catching Exception
marx3 May 24, 2011 9:10 AM (in response to stormqueen)If exception happens in ajax action with partial page update, redirect will not work too.
-
6. Re: Problems with redirect after catching Exception
ssachtleben.ssachtleben.gmail.com May 24, 2011 9:38 AM (in response to stormqueen)I have another question about Seam Catch since I missed Jason in the last three days in irc. I catch several exceptions and redirect to my startpage which works fine. But I have still two problems with that.
1) The full stacktrace will be posted in server logs - I see that the handler catch the exception after that log message. Is it possible to prevent that logging? If 100 users cause that exception in 5 minutes the logs will be explode...
2) How to add messages after the redirect? I have tried to set a message below but it doesnt get displayed?!?
Thanks :)
@Inject private FacesContext facesContext; @Inject private Messages messages; @Inject @ContextPath private String contextPath; void handleForumNotFoundException(@Handles(precedence = 100) CaughtException<ForumNotFoundException> event, Logger log) { String redirectTo = contextPath + "/forums.html"; log.info("Handle ForumNotFoundException -> redirect to: " + redirectTo); event.markHandled(); try { facesContext.getExternalContext().redirect(redirectTo); } catch (IOException e) { e.printStackTrace(); } messages.error(new BundleKey("messages", "exceptionhandler.error.ForumNotFoundException")).defaults("Board forum not found"); }
-
7. Re: Problems with redirect after catching Exception
lightguard May 24, 2011 2:08 PM (in response to stormqueen)
Marek Nazarko wrote on May 24, 2011 09:10:
If exception happens in ajax action with partial page update, redirect will not work too.That's probably a JSF issue.
-
8. Re: Problems with redirect after catching Exception
lightguard May 24, 2011 2:15 PM (in response to stormqueen)
Sebastian Sachtleben wrote on May 24, 2011 09:38:
I have another question about Seam Catch since I missed Jason in the last three days in irc. I catch several exceptions and redirect to my startpage which works fine. But I have still two problems with that.
1) The full stacktrace will be posted in server logs - I see that the handler catch the exception after that log message. Is it possible to prevent that logging? If 100 users cause that exception in 5 minutes the logs will be explode...Yeah, that's a Mojarra issue, they fixed it (set it to trace level instead of info or debug) in the 2.1 release. Very annoying I agree.
2) How to add messages after the redirect? I have tried to set a message below but it doesnt get displayed?!?
Thanks :)@Inject private FacesContext facesContext; @Inject private Messages messages; @Inject @ContextPath private String contextPath; void handleForumNotFoundException(@Handles(precedence = 100) CaughtException<ForumNotFoundException> event, Logger log) { String redirectTo = contextPath + "/forums.html"; log.info("Handle ForumNotFoundException -> redirect to: " + redirectTo); event.markHandled(); try { facesContext.getExternalContext().redirect(redirectTo); } catch (IOException e) { e.printStackTrace(); } messages.error(new BundleKey("messages", "exceptionhandler.error.ForumNotFoundException")).defaults("Board forum not found"); }
I believe this is due to the phase in which the handler is being executed. I've been very disillusioned in the exception handling available in JSF. An option (and would really help us figure out what's going on here) would be to do this with standard JSF2 exception handling and see what the outcome is. If it's the same, then it's something that will need to be changed in JSF, otherwise we'll have to look at our integration and see what's going on. If you don't mind doing that Sebastian, it would be a great help.
-
9. Re: Problems with redirect after catching Exception
ssachtleben.ssachtleben.gmail.com May 25, 2011 1:23 AM (in response to stormqueen)I think I'm also in render phase since my view invokes somewhere an method which cause the exception if the forum is not found in database depending on the url parameter.
Do u mean this?
I saw someone is using this inside of the exception handler:
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Error occured"));
If you mean that I could try it out.
-
10. Re: Problems with redirect after catching Exception
ssachtleben.ssachtleben.gmail.com Jun 1, 2011 5:39 AM (in response to stormqueen)I have tried to add a FacesMessage with the normal jsf 2 error catching but its gone also after redirect. If I use s:viewAction with pretty id as return string the redirect works with the facesmessage but I cant get it to work with the error catching at all.