com.sun.jsfcl.app
Class ViewHandlerImpl

java.lang.Object
  extended by javax.faces.application.ViewHandler
      extended by com.sun.jsfcl.app.ViewHandlerImpl
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.faces.event.PhaseListener

public class ViewHandlerImpl
extends javax.faces.application.ViewHandler
implements javax.faces.event.PhaseListener

ViewHandler implementation that allows events to be triggered upon the occurrence of specific ViewHandler method calls. This implementation also posts relevant lifecycle events to initialized page beans, so it also implements PhaseListener.

FIXME - may need to provide an implementation of Lifecycle as well, in order to ensure that afterRenderResponse works even in the face of exceptions thrown by application code.

See Also:
Serialized Form

Field Summary
static java.lang.String CREATED_VIEW
          The request scope attribute under which we store the view id when createView() is called.
 
Fields inherited from class javax.faces.application.ViewHandler
CHARACTER_ENCODING_KEY, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME
 
Constructor Summary
ViewHandlerImpl(javax.faces.application.ViewHandler handler)
          Construct a new ViewHandlerImpl that delegates to the specified ViewHandler instance.
 
Method Summary
 void afterPhase(javax.faces.event.PhaseEvent event)
          Process the specified after phase event.
 void beforePhase(javax.faces.event.PhaseEvent event)
          Process the specified before phase event.
 java.util.Locale calculateLocale(javax.faces.context.FacesContext context)
          Return an appropriate Locale to use for this and subsequent requests for the current client.
 java.lang.String calculateRenderKitId(javax.faces.context.FacesContext context)
          Return an appropriate RenderKit identifier for this and subsequent requests from the current client.
 javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context, java.lang.String viewId)
          Create and return a new UIViewRoot instance initialized with information from this FacesContext for the specified viewId.
 java.lang.String getActionURL(javax.faces.context.FacesContext context, java.lang.String viewId)
          Return a URL suitable for rendering that selects the specified view identifier.
 javax.faces.event.PhaseId getPhaseId()
          Return PhaseId.ANY_PHASE because we are interested in all phase events.
 java.lang.String getResourceURL(javax.faces.context.FacesContext context, java.lang.String path)
          Return a URL suitable for rendering that selects the specified resource.
 void renderView(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewRoot)
          Perform the necessary actions to render the specified view as part of the current response.
 javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context, java.lang.String viewId)
          Perform necessary actions to restore the specified view and return a corresponding UIViewRoot.
 void writeState(javax.faces.context.FacesContext context)
          Take appropriate action to save the current state information.
 
Methods inherited from class javax.faces.application.ViewHandler
calculateCharacterEncoding, initView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATED_VIEW

public static final java.lang.String CREATED_VIEW

The request scope attribute under which we store the view id when createView() is called.

See Also:
Constant Field Values
Constructor Detail

ViewHandlerImpl

public ViewHandlerImpl(javax.faces.application.ViewHandler handler)

Construct a new ViewHandlerImpl that delegates to the specified ViewHandler instance.

Parameters:
handler - The ViewHandler instance to which we will delegate
Method Detail

calculateLocale

public java.util.Locale calculateLocale(javax.faces.context.FacesContext context)

Return an appropriate Locale to use for this and subsequent requests for the current client.

Specified by:
calculateLocale in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
Throws:
java.lang.NullPointerException - if context is null

calculateRenderKitId

public java.lang.String calculateRenderKitId(javax.faces.context.FacesContext context)

Return an appropriate RenderKit identifier for this and subsequent requests from the current client.

Specified by:
calculateRenderKitId in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
Throws:
java.lang.NullPointerException - if context is null

createView

public javax.faces.component.UIViewRoot createView(javax.faces.context.FacesContext context,
                                                   java.lang.String viewId)

Create and return a new UIViewRoot instance initialized with information from this FacesContext for the specified viewId.

Specified by:
createView in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
viewId - View identifier of the view to be created
Throws:
java.lang.NullPointerException - if context or viewId is null

getActionURL

public java.lang.String getActionURL(javax.faces.context.FacesContext context,
                                     java.lang.String viewId)

Return a URL suitable for rendering that selects the specified view identifier.

Specified by:
getActionURL in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
viewId - View identifier of the desired view
Throws:
java.lang.NullPointerException - if context or viewId is null

getResourceURL

public java.lang.String getResourceURL(javax.faces.context.FacesContext context,
                                       java.lang.String path)

Return a URL suitable for rendering that selects the specified resource.

Specified by:
getResourceURL in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
path - Context-relative resource path to reference
Throws:
java.lang.NullPointerException - if context or path is null

renderView

public void renderView(javax.faces.context.FacesContext context,
                       javax.faces.component.UIViewRoot viewRoot)
                throws java.io.IOException,
                       javax.faces.FacesException

Perform the necessary actions to render the specified view as part of the current response.

Specified by:
renderView in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
viewRoot - View to be rendered
Throws:
java.lang.NullPointerException - if context or viewRoot is null
java.io.IOException
javax.faces.FacesException

restoreView

public javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context,
                                                    java.lang.String viewId)

Perform necessary actions to restore the specified view and return a corresponding UIViewRoot. If there is no view information to be restored, return null.

Specified by:
restoreView in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
viewId - View identifier of the view to be restored
Throws:
java.lang.NullPointerException - if context or viewId is null

writeState

public void writeState(javax.faces.context.FacesContext context)
                throws java.io.IOException

Take appropriate action to save the current state information.

Specified by:
writeState in class javax.faces.application.ViewHandler
Parameters:
context - FacesContext for the current request
Throws:
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if context is null

getPhaseId

public javax.faces.event.PhaseId getPhaseId()

Return PhaseId.ANY_PHASE because we are interested in all phase events.

Specified by:
getPhaseId in interface javax.faces.event.PhaseListener

beforePhase

public void beforePhase(javax.faces.event.PhaseEvent event)

Process the specified before phase event.

Specified by:
beforePhase in interface javax.faces.event.PhaseListener
Parameters:
event - PhaseEvent to be processed

afterPhase

public void afterPhase(javax.faces.event.PhaseEvent event)

Process the specified after phase event.

Specified by:
afterPhase in interface javax.faces.event.PhaseListener
Parameters:
event - PhaseEvent to be processed