Skip to main content

biz logic error handling in JSF

No replies
Joined: 2004-07-02

I'm not sure if this is the right place for such a question, but I'm using JSF w/ Glassfish and wonder if any other engineer had solved this problem: how can I omnipotently intercept business logic errors and handle them gracefully by forwarding to a new page, before the socket starts to get written to?
In Struts it was pretty straightforward. All the biz logic is in the Action, which produces one big Form object w/ all the data the JSP needs. One can easily subclass the RequestProcessor, try/catch the action and forward to an error page, with little risk that the JSP will fail at execution time since all the data has already been prepared for consumption.
With JSF, the action command will hit just one JSF bean and command links will not execute any biz logic, but then satellite JSF components on the target page needs data to display themselves and will call back-end services in the getter methods after the RENDER_RESPONSE phase has already started. Then, it's beyond the scope of the ActionListener, I couldn't find a way to intercept exceptions during that phase w/ a PhaseListener, and some of the response may already have been committed to the socket, thereby preventing anyway to forward to a different page...
Is there a solution to this problem with JSF?
How can I force business logic to be executed before the rendering phase and intercept any exception, which may occur as a result, to have a chance to gracefully handle it before the failed page starts to get written out to the client browser?