Friday, July 11, 2014

Difference between Request MVC and Component MVC

In request (action) based MVC, a single front controller servlet will delegate to action models based on request URL/params. You works directly with raw HttpServletRequest and HttpServletResponse objects in the action model. You've to write code yourself to gather, convert and validate the request parameters and if necessary update the model values before you can ever invoke the business action.
In component based MVC, a single front controller will gather, convert and validate request parameters and update the model values itself so that you only need to worry about the business action yourself. How the controller needs to gather/convert/validate/update the values is definied in a single place, the view. Since that's not possible with "plain" HTML, a specific markup language is required to achieve the goal. In case of JSF 2.0, that's XML (XHTML) based. You use XML to define UI components which in turn contain information about how the controller should gather/convert/validate/update the values and itself generate the necessary HTML representation.
Advantages and disadvantages should be clear at this point: With a request based MVC framework you need to write more code yourself to achieve the goal. However you end up with much more fine grained control over the process and the HTML/CSS/JS output. With a component based MVC framework you don't need to write much code yourself. However you have less fine grained control over the process and the HTML/CSS/JS output. So if you'd like to do things a bit differently than the standard describes, you'll waste a lot more time in a component based MVC framework.

See also:

No comments:

Post a Comment