org.apache.shale.view
Interface ViewController

All Known Implementing Classes:
AbstractViewController

public interface ViewController

ViewController is a "backing bean" interface which adds several extension points to the standard JavaServer Faces lifecycle. The extension points help Shale interact with JSF UIComponents.

A "backing bean" represents a convenient place to retrieve and store dynamic values associated with the user interface components that comprise the view, as well as to code event handlers triggered by state changes on those components. A JavaServer Faces view is most often a JSP page, but any JSF view rendering system can be used.

Essentially, the ViewController is a View Helper interface for a backing bean and its associated View.

NOTE - JavaServer Faces imposes no restrictions on the inheritance hierarchy (or interface implementation) for backing beans associated with a view. Therefore, the use of this interface for your own backing beans is entirely optional. That being said, having your backing beans implement this interface (typically by extending AbstractViewController) will receive the benefit of the extra services described by this interface, all of which will be provided automatically.

To be useful, the ViewController must be plugged into the application lifecycle through a custom JSF ViewHandler, like the ViewViewHandler.

Registering a ViewController backing bean

For each JSF view that you wish to associate with a ViewController backing bean, you must do the following:

Since the ViewController is a backing bean, you have the option of establishing other links with the UIComponents, such as:

ViewController Lifecycle

Once you have configured the use of a ViewController backing bean associated with a JSF view, Shale will provide the following services:

$Id: ViewController.java 464373 2006-10-16 04:21:54Z rahul $


Method Summary
 void destroy()
          Called after the JSF request processing lifecycle has been completed for the current request.
 void init()
          Called after this ViewController has been instantiated, and after all of the property setters specified above have been called, but before the JSF request processing lifecycle processing and events related to our corresponding view are executed.
 boolean isPostBack()
          Return a flag indicating whether this request is a "post back" (that is, the view was restored in order to respond to a submit from the client), or a newly created view.
 void preprocess()
          Called after the component tree has been restored (in Restore View phase), if the current request is a postback.
 void prerender()
          Called before the Render Response processing for this request is performed, whether or not this is a post back request.
 void setPostBack(boolean postBack)
          Set a flag indicating whether this request is a "post back" (that is, the view was restored in order to respond to a submit from the client), or a newly created view.
 

Method Detail

isPostBack

boolean isPostBack()

Return a flag indicating whether this request is a "post back" (that is, the view was restored in order to respond to a submit from the client), or a newly created view. This method must return any value passed to the setPostBack() method.


setPostBack

void setPostBack(boolean postBack)

Set a flag indicating whether this request is a "post back" (that is, the view was restored in order to respond to a submit from the client), or a newly created view.

Parameters:
postBack - true for a post back request, or false for a newly created request

destroy

void destroy()

Called after the JSF request processing lifecycle has been completed for the current request. This allows a ViewController to clean up any resources it has allocated (perhaps during earlier execution of the init() method).


init

void init()

Called after this ViewController has been instantiated, and after all of the property setters specified above have been called, but before the JSF request processing lifecycle processing and events related to our corresponding view are executed. Within this method, you may consult the isPostBack() method to vary the initialization behavior based on whether a post back is being processed or not.


preprocess

void preprocess()

Called after the component tree has been restored (in Restore View phase), if the current request is a postback. If this view is only going to be rendered (because of either direct navigation, or because this view was navigated to from a different view), this method will NOT be called. As such, this method makes a good place to acquire information from your model tier that will be required during the execution of the Apply Request Values through Invoke Application phases of the request processing lifecycle.


prerender

void prerender()

Called before the Render Response processing for this request is performed, whether or not this is a post back request. This method will be called only for the view that will actually be rendered. For example, it will not be called if you have performed navigation to a different view. As such, it makes a good place to acquire information from your model tier that is required to complete this view's presentation.



Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.