When it comes to JSF, I’ve had trouble distinguishing where certain objects I create fit into the overall MVC pattern. The View is simple enough since that’s handled by the .xhtml template but when it comes to objects like:
- Action/Change Listeners
- PhaseListeners
- Validators
- Navigation Beans
- Converters
- Filters
At first I’d assume some of these belong to the Controller but I’ve seen a number of statements here and elsewhere on the web stating that for most developers using an MVC framework, specifically JSF, the majority/entirety of the Controller is already implemented by the framework.
The following Q&A: https://stackoverflow.com/questions/10111387/understanding-jsf-as-a-mvc-framework
, while very informative still leaves me feeling pretty vague on the matter. The accepted answer states that consumers of JSF do not implement Controllers while the thesis linked to at the bottom of the answer clearly states that Listeners are a part of the Controller pattern.
In essence the accepted answer in the link you provided is correct. The MVC pattern only makes sense when considering that M, V, and C can all directly communicate with each other. This is possible in a desktop application, however the web is inherently stateless and request response based. JSF and other component based web frameworks seek to bridge that gap. They do this by providing to you a prebuilt Controller in FacesServlet.
What does that make Managed Beans and PhaseListeners then? BalusC says is best here:
https://stackoverflow.com/questions/5104094/what-components-are-mvc-in-jsf-mvc-framework
The combination of all your JSF code can be considered the traiditional View in the MVC pattern, the View Model being your entities, and the View Logic is your Managed Beans, Converters, EL Expressions, Validators, and finally PhaseListeners. They only make a difference with respect to processing logic that manipulates the View itself and the ViewModel.
M – Application and DAO Tiers (M – Entities, V – JSF Marktup, C – JSF Code and Logic) C – FacesServlet