On 12/21/05, Darren Boyd <[EMAIL PROTECTED]> wrote: > > > I've come across an issue with the ShalePhaseListener that occurs > whenever a ViewController throws an exception. > > We are using MyFaces 1.1.1 in a project but have also included > shale-core.jar and shale-spring.jar to take advantage of the shale's > ViewController functionality (which is a lifesaver for us, btw, thanks!). > > We are encountering a problem whenever our ViewController throws an > exception from a ViewController.prerender() call. The exception makes > its way to the container which is configured to forward to a custom > error page. This error page is a JSF page (which is not mapped to a > ViewController) and the PhaseListener calls the same > ViewController.prerender() a second time which generates the same > exception. At this point the container (Tomcat) simply generates the > default 'Error 500' page. > > The problem seems to be a simple piece of code in the ShaleViewHandler. > In the beforeRenderResponse(PhaseEvent) method we have the following... > > Map map = > event.getFacesContext().getExternalContext().getRequestMap(); > ViewController vc = (ViewController) > map.get(ShaleConstants.VIEW_RENDERED); > if (vc == null) { > return; > } > vc.prerender(); > map.remove(ShaleConstants.VIEW_RENDERED); > > > I believe that the map.remove() statement should be called before the > vc.prerender(). That should ensure that the prerender is only called > once in a request. This same issue might exist for preprocess() as > well, but I'm not that familiar with the code to completely understand > it. I am confident it isn't an issue for init() or destroy().
Exception handling in ViewControllers is definitely an area that needs improvement ... and a bugzilla ticket would help focus attention on that topic. Calling prerender() twice is *definitely* a bug. I would also bet that we are not always calling destroy() right now (if exceptions were thrown), despite our promise to "always call destroy() if init() was called". I suspect that the particular issue with calling prerender() twice would be better addressed by an overall architectural look at how to deal with exceptions, rather than trying to hack the map manipulation for this particular issue in isolation ... but go ahead and put in the suggested change above just to keep us cognizant of what kinds of things need to be addressed. Thanks for your feedback on Shale! Craig