The Corporate Code


Exception handling And Jsf, A nightmare !!
May 1, 2007, 22:22
Filed under: Tech

Since the application is rather huge, and exception handling isn’t something that has been taken into account when writing the drafts for JSF, it took me some time to find a decent way to implement exception handling. I came up with two possible solutions, but after further testing it turned out that only one of them actually worked. Sadly it was the one that I felt, was the worst scenario.

First I tried to delegate the Faces servlet and tried to catch any exceptions there. that would have been a nice solution, since all exception handling would have been centralized and I wouldn’t have to have to much boiler plate code inside my application. But, as it turned out, this solution didn’t work :( After carefully testing the mock-up I had to come to the conclusion that delegating a Faces servlet is not a good way to go, certainly not a good way if your using icefaces.

The second solution was rather nasty but, i went on with it anyway since I couldn’t find any better solution after searching the net. I let every exception get back to the event methods and catch it there. Once I had the exception there, I was able to pass it to an exception handler class, which would take care of the logging and displaying a nice pop up with some info for the user.

If you ever think of building a corporate application using JSF, don’t ! :) In my opinion it lacks some basic functionality and basically it isn’t ready for usage in real world applications yet. If you really want JSF then don’t use it as a stand-alone framework, I think it would be better to use it in combination with Spring or Struts.


1 Comment so far
Leave a comment

Definitely not true. You can love or hate JSF. And yes, there are numerous reasons to hate JSF, but this is one is not correct.

JSF provides extension points for almost everything, without the need for hacks like extending the Faces Servlet. For example, you could implement a javax.faces.event.ActionListener and put your error handling logic there. I’ve used it in some projects and it works fine.

Comment by Jan-Kees van Andel




Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>