Single entry/exit point design in JSF 2.0

眉间皱痕 提交于 2019-12-12 04:33:42

问题


I want to design my application in JSF 2.0 with single entry/exit point for all the requests and responses so that they can be routed through a single managedBean/controller.

The purpose of having this design is to catch my all business exceptions at common place and also it would be easy for me to check for the validation of session for each new request.

One of the option I see is ServletFilter but I am not sure if this would be the best approach with JSF 2.0.


回答1:


The purpose of having this design is to catch my all business exceptions at common place

Just implement a custom JSF ExceptionHandler.


and also it would be easy for me to check for the validation of session for each new request.

This makes no sense. The container does it already by itself. I believe that you're concretely asking to check a session attribute representing the logged-in user. For that a servlet Filter is indeed the most sensible approach. Some may opt to use a JSF PhaseListener for that, but this is tight coupled to JSF requests and does not kick in on other requests.



来源:https://stackoverflow.com/questions/13892473/single-entry-exit-point-design-in-jsf-2-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!