Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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: 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.

share|improve this question

migrated from stackoverflow.com Jan 18 '13 at 18:34

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 1 down vote accepted

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:

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.