Top Description Fields Constructors Methods
com.sun.faces.application.view

public Class JspViewHandlingStrategy

extends ViewHandlingStrategy
Class Inheritance
Static Imports
com.sun.faces.config.WebConfiguration.WebContextInitParameter.ResponseBufferSize, com.sun.faces.util.RequestStateManager.AFTER_VIEW_CONTENT, .Util.isViewPopulated, .Util.setViewPopulated, java.lang.Integer.parseInt, java.util.logging.Level.FINE, javax.faces.FactoryFinder.RENDER_KIT_FACTORY

This ViewHandlingStrategy handles JSP-based views.

Field Summary

Modifier and TypeField and Description
private static final Logger
private int
Inherited from com.sun.faces.application.view.ViewHandlingStrategy:
associatewebConfig

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
buildView(FacesContext context, UIViewRoot view)

Implements abstract javax.faces.view.ViewDeclarationLanguage.buildView.

Take any actions specific to this VDL implementation to cause the argument UIViewRoot which must have been created via a call to createView, to be populated with children.

private void
doRenderView(FacesContext
the FacesContext for the current request
context
,
UIViewRoot
the view to render
viewToRender
)

This is a separate method to account for handling the content after the view tag.

private boolean

Returns:

true if the response should be immediately flushed to the client, otherwise false
executePageToBuildView
(FacesContext
the FacesContext for the current request
context
,
UIViewRoot
the view to build
viewToExecute
)

Execute the target view.

public BeanInfo
getComponentMetadata(FacesContext
The FacesContext for this request.
context
,
Resource
The Resource that represents the component.
componentResource
)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getComponentMetadata.

Not supported in JSP-based views.

public String
getId()

Overrides javax.faces.view.ViewDeclarationLanguage.getId.

Returns a non-null String that can be used to identify this view declaration language.

public Resource
getScriptComponentResource(FacesContext
The FacesContext for this request.
context
,
Resource
The Resource that represents the component.
componentResource
)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getScriptComponentResource.

Not supported in JSP-based views.

public StateManagementStrategy
getStateManagementStrategy(FacesContext
the FacesContext for the current request.
context
,
String
the view id.
viewId
)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getStateManagementStrategy.

For implementations that want to control the implementation of state saving and restoring, the StateManagementStrategy allows them to do so.

public ViewMetadata
getViewMetadata(FacesContext
The FacesContext for this request.
context
,
String
the view id from whith to extract the metadata
viewId
)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getViewMetadata.

Not supported in JSP-based views.

public Stream<String>
getViews(FacesContext
The FacesContext for this request.
context
,
String
The initial path from which to start looking for views
path
,
ViewVisitOption...
The options to influence the traversal. See ViewVisitOption for details on those.
options
)

Overrides javax.faces.view.ViewDeclarationLanguage.getViews.

Not supported in JSP-based views.

public Stream<String>
getViews(FacesContext
The FacesContext for this request.
context
,
String
The initial path from which to start looking for views
path
,
int
The absolute maximum depth of nested directories to visit counted from the root (/).
maxDepth
,
ViewVisitOption...
The options to influence the traversal. See ViewVisitOption for details on those.
options
)

Overrides javax.faces.view.ViewDeclarationLanguage.getViews.

Not supported in JSP-based views.

private static ViewHandlerResponseWrapper

Returns:

the current response wrapped with ViewHandlerResponseWrapper
getWrapper
(ExternalContext
the ExternalContext for this request
extContext
)

Simple utility method to wrap the current response with the ViewHandlerResponseWrapper.

public boolean
handlesViewId(String
the view ID
viewId
)

Implements abstract com.sun.faces.application.view.ViewHandlingStrategy.handlesViewId.

This ViewHandlingStrategy should be the last one queried and as such we return true.
public void
renderView(FacesContext
the FacesContext for this request.
context
,
UIViewRoot
the UIViewRoot from an early call to createView or restoreView.
view
)

Implements abstract javax.faces.view.ViewDeclarationLanguage.renderView.

Render a view rooted at argumentview.

Inherited from com.sun.faces.application.view.ViewHandlingStrategy:
createViewrestoreView

Field Detail

LOGGERback to summary
private static final Logger LOGGER
responseBufferSizeback to summary
private int responseBufferSize

Constructor Detail

JspViewHandlingStrategyback to summary
public JspViewHandlingStrategy()

Method Detail

buildViewback to summary
public void buildView(FacesContext context, UIViewRoot view) throws IOException

Implements abstract javax.faces.view.ViewDeclarationLanguage.buildView.

Doc from javax.faces.view.ViewDeclarationLanguage.buildView.

Take any actions specific to this VDL implementation to cause the argument UIViewRoot which must have been created via a call to createView, to be populated with children.

The Facelets implementation must insure that markup comprising the view must be executed, with the javax.faces.component.UIComponent instances in the view being encountered in the same depth-first order as in other lifecycle methods defined on UIComponent, and added to the view (but not rendered) during the traversal. The runtime must guarantee that the view must be fully populated before any of the following happen.

If the root is already populated with children, the view must still be re-built, but care must be taken to ensure that the existing components are correctly paired up with their VDL counterparts in the VDL page. Also, any system events that would normally be generated during the adding or removing of components from the view must be temporarily disabled during the creation of the view and then re-enabled when the view has been built.

Annotations
@Override
Exceptions
IOException:
if view cannot be built for any reason
See Also
javax.faces.view.ViewDeclarationLanguage#buildView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
doRenderViewback to summary
private void doRenderView(FacesContext context, UIViewRoot viewToRender) throws IOException

This is a separate method to account for handling the content after the view tag.

Create a new ResponseWriter around this response's Writer. Set it into the FacesContext, saving the old one aside.

call encodeBegin(), encodeChildren(), encodeEnd() on the argument UIViewRoot.

Restore the old ResponseWriter into the FacesContext.

Write out the after view content to the response's writer.

Flush the response buffer, and remove the after view content from the request scope.

Parameters
context:FacesContext

the FacesContext for the current request

viewToRender:UIViewRoot

the view to render

Exceptions
IOException:
if an error occurs rendering the view to the client
FacesException:
if some error occurs within the framework processing
executePageToBuildViewback to summary
private boolean executePageToBuildView(FacesContext context, UIViewRoot viewToExecute) throws IOException

Execute the target view. If the HTTP status code range is not 2xx, then return true to indicate the response should be immediately flushed by the caller so that conditions such as 404 are properly handled.

Parameters
context:FacesContext

the FacesContext for the current request

viewToExecute:UIViewRoot

the view to build

Returns:boolean

true if the response should be immediately flushed to the client, otherwise false

Exceptions
IOException:
if an error occurs executing the page
getComponentMetadataback to summary
public BeanInfo getComponentMetadata(FacesContext context, Resource componentResource)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getComponentMetadata.

Not supported in JSP-based views.

Parameters
context:FacesContext

Doc from javax.faces.view.ViewDeclarationLanguage.getComponentMetadata.

The FacesContext for this request.

componentResource:Resource

Doc from javax.faces.view.ViewDeclarationLanguage.getComponentMetadata.

The Resource that represents the component.

Returns:BeanInfo

Doc from javax.faces.view.ViewDeclarationLanguage.getComponentMetadata.

the component metadata

Annotations
@Override
See Also
javax.faces.view.ViewDeclarationLanguage#getComponentMetadata(javax.faces.context.FacesContext, javax.faces.application.Resource)
getIdback to summary
public String getId()

Overrides javax.faces.view.ViewDeclarationLanguage.getId.

Doc from javax.faces.view.ViewDeclarationLanguage.getId.

Returns a non-null String that can be used to identify this view declaration language.

The default implementation returns the fully qualified class name of the view declaration language implementation. Subclasses may override to provide a more meaningful id.

Returns:String

the id of this view declaration language

Annotations
@Override
getScriptComponentResourceback to summary
public Resource getScriptComponentResource(FacesContext context, Resource componentResource)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getScriptComponentResource.

Not supported in JSP-based views.

Parameters
context:FacesContext

Doc from javax.faces.view.ViewDeclarationLanguage.getScriptComponentResource.

The FacesContext for this request.

componentResource:Resource

Doc from javax.faces.view.ViewDeclarationLanguage.getScriptComponentResource.

The Resource that represents the component.

Returns:Resource

Doc from javax.faces.view.ViewDeclarationLanguage.getScriptComponentResource.

the Resource corresponding to the argument componentResource

Annotations
@Override
See Also
javax.faces.view.ViewDeclarationLanguage#getScriptComponentResource(javax.faces.context.FacesContext, javax.faces.application.Resource)
getStateManagementStrategyback to summary
public StateManagementStrategy getStateManagementStrategy(FacesContext context, String viewId)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getStateManagementStrategy.

Doc from javax.faces.view.ViewDeclarationLanguage.getStateManagementStrategy.

For implementations that want to control the implementation of state saving and restoring, the StateManagementStrategy allows them to do so. Returning null indicates that the implementation wishes the runtime to handle the state saving and restoring. Implementations that provide the VDL for Facelets for JSF 2.0 and later must return non-null from this method.

Parameters
context:FacesContext

the FacesContext for the current request.

viewId:String

the view id.

Returns:StateManagementStrategy

the strategy as specified above

Annotations
@Override
getViewMetadataback to summary
public ViewMetadata getViewMetadata(FacesContext context, String viewId)

Implements abstract javax.faces.view.ViewDeclarationLanguage.getViewMetadata.

Not supported in JSP-based views.

Parameters
context:FacesContext

Doc from javax.faces.view.ViewDeclarationLanguage.getViewMetadata.

The FacesContext for this request.

viewId:String

Doc from javax.faces.view.ViewDeclarationLanguage.getViewMetadata.

the view id from whith to extract the metadata

Returns:ViewMetadata

Doc from javax.faces.view.ViewDeclarationLanguage.getViewMetadata.

the view metadata

Annotations
@Override
See Also
javax.faces.view.ViewDeclarationLanguage#getViewMetadata(javax.faces.context.FacesContext, String)
getViewsback to summary
public Stream<String> getViews(FacesContext context, String path, ViewVisitOption... options)

Overrides javax.faces.view.ViewDeclarationLanguage.getViews.

Not supported in JSP-based views.

Parameters
context:FacesContext

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The FacesContext for this request.

path:String

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The initial path from which to start looking for views

options:ViewVisitOption[]

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The options to influence the traversal. See ViewVisitOption for details on those.

Returns:Stream<String>

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

the Stream of view ids

Annotations
@Override
See Also
javax.faces.view.ViewDeclarationLanguage#getViews(FacesContext, String, ViewVisitOption...)
getViewsback to summary
public Stream<String> getViews(FacesContext context, String path, int maxDepth, ViewVisitOption... options)

Overrides javax.faces.view.ViewDeclarationLanguage.getViews.

Not supported in JSP-based views.

Parameters
context:FacesContext

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The FacesContext for this request.

path:String

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The initial path from which to start looking for views

maxDepth:int

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The absolute maximum depth of nested directories to visit counted from the root (/).

options:ViewVisitOption[]

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

The options to influence the traversal. See ViewVisitOption for details on those.

Returns:Stream<String>

Doc from javax.faces.view.ViewDeclarationLanguage.getViews.

the Stream of view ids

Annotations
@Override
See Also
javax.faces.view.ViewDeclarationLanguage#getViews(FacesContext, String, int, ViewVisitOption...)
getWrapperback to summary
private static ViewHandlerResponseWrapper getWrapper(ExternalContext extContext)

Simple utility method to wrap the current response with the ViewHandlerResponseWrapper.

Parameters
extContext:ExternalContext

the ExternalContext for this request

Returns:ViewHandlerResponseWrapper

the current response wrapped with ViewHandlerResponseWrapper

handlesViewIdback to summary
public boolean handlesViewId(String viewId)

Implements abstract com.sun.faces.application.view.ViewHandlingStrategy.handlesViewId.

This ViewHandlingStrategy should be the last one queried and as such we return true.

Parameters
viewId:String

Doc from com.sun.faces.application.view.ViewHandlingStrategy.handlesViewId.

the view ID

Returns:boolean

Doc from com.sun.faces.application.view.ViewHandlingStrategy.handlesViewId.

true if this ViewHandlingStrategy handles the the view type represented by viewId

Annotations
@Override
See Also
com.sun.faces.application.view.ViewHandlingStrategy#handlesViewId(String)
renderViewback to summary
public void renderView(FacesContext context, UIViewRoot view) throws IOException

Implements abstract javax.faces.view.ViewDeclarationLanguage.renderView.

Doc from javax.faces.view.ViewDeclarationLanguage.renderView.

Render a view rooted at argumentview. See section JSF.7.7.2 for the specification of the default implementation.

Parameters
context:FacesContext

the FacesContext for this request.

view:UIViewRoot

the UIViewRoot from an early call to createView or restoreView.

Annotations
@Override
Exceptions
IOException:
if the view cannot be rendered for any reason
See Also
javax.faces.view.ViewDeclarationLanguage#renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)