Thursday, May 3, 2007

JSF MVC Implementation

Still reading Rick Hightower's article on JSF.


This image has been referenced from Rick Hightower's article.

The JSP page (essentially the tags) is bound to a server side view_root that maintains the state of the UI components. The view root is a composite just like Swing components. Any changes a user makes in their browser's view get reflected in the state of the view root. The view is also linked to properties (or nested properties) of a backing bean. It is recommended that we do not put business logic in the backing bean, they are meant to mediate between the view and the model. At first I thought, why do we need these backing beans? The properties can be set in the View Root objects, and they can handle the events as well, but I think there is a good reason for them. The View Root components are written by the component provider. We do not have control on them. However our application needs to have event handlers, and maybe transfer objects. These are bound to the view through the backing beans. So the backing beans act as the glue between the view and the model. Is there a cleaner way to do this? Maybe not.

How do the values from the front end actually get set in the backing bean? I think the components in the view root will invoke the setters when they are updated. Then exactly what role does the faces Servlet play?

Update:
The FacesServlet handles the JSF lifesycle.

No comments: