|
JSF-Spring | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.view.AbstractView org.springframework.web.servlet.view.AbstractUrlBasedView de.mindmatters.faces.spring.context.servlet.FacesView
public class FacesView
Wrapper for a JSP or other resource within the same faces web application.
Rendering is delegated to the Lifecycle
of the underlying JSF
implementation.
UIViewRoot
creation is done by this class (if not already created by
other components such as a NavigationHandler).
Typical usage with FacesViewResolver
would look as follows, from the
perspective of the FacesDispatcherServlet
context definition:
<bean id="viewResolver" class="de.mindmatters.faces.spring.context.servlet.FacesViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean>Every view name returned from a handler will be translated to a JSP resource (for example: "myView" -> "/WEB-INF/jsp/myView.jsp"), using this view class by default.
Lifecycle.render(FacesContext)
,
ViewHandler.createView(FacesContext, String)
Field Summary |
---|
Fields inherited from class org.springframework.web.servlet.view.AbstractView |
---|
DEFAULT_CONTENT_TYPE |
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
logger |
Constructor Summary | |
---|---|
FacesView()
Constructor for use as a bean. |
|
FacesView(java.lang.String url)
Create a new FacesView with the given URL url . |
|
FacesView(UIViewRoot viewRoot)
Create a new FacesView with the given UIViewRoot
viewRoot . |
Method Summary | |
---|---|
void |
afterPropertiesSet()
Resolves the appropriate Lifecycle depending on the configured
lifecycle-id. |
protected void |
exposeHelpers(javax.servlet.http.HttpServletRequest request)
Expose helpers unique to each rendering operation. |
protected void |
exposeViewRootIfNecessary(FacesContext context,
java.lang.String viewId)
Creates and exposes the UIViewRoot to the given
FacesContext if necessary. |
protected Lifecycle |
getLifecycle()
|
protected void |
initFacesView()
This hook method will be invoked after any bean properties have been set and the Lifecycle has been resolved. |
protected java.lang.String |
prepareViewIdForRendering(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Prepare for rendering, and determine the the view id to render by the resolved Lifecycle . |
protected void |
render(FacesContext context)
Renders the appropriate view with the help of the resolved Lifecycle . |
protected void |
renderMergedOutputModel(java.util.Map model,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Subclasses must implement this method to actually render the view. |
void |
setLifecycleId(java.lang.String lifecycleId)
Sets the lifecycle-id for resolving the appropriate Lifecycle . |
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView |
---|
getUrl, setUrl, toString |
Methods inherited from class org.springframework.web.servlet.view.AbstractView |
---|
addStaticAttribute, createRequestContext, exposeModelAsRequestAttributes, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute |
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
---|
getServletContext, getTempDir, getWebApplicationContext, isContextRequired, setServletContext |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FacesView()
public FacesView(java.lang.String url)
url
.
url
- the URL to forward topublic FacesView(UIViewRoot viewRoot)
UIViewRoot
viewRoot
.
viewRoot
- the UIViewRoot
to renderMethod Detail |
---|
public final void afterPropertiesSet() throws java.lang.Exception
Lifecycle
depending on the configured
lifecycle-id.
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class AbstractUrlBasedView
java.lang.Exception
- in the case of errorssetLifecycleId(String)
protected void initFacesView()
Lifecycle
has been resolved. The default implementation
is empty; subclasses may override this method to perform any
initialization they require.
protected final Lifecycle getLifecycle()
Lifecycle
that will be used by this
View
for rendering.public final void setLifecycleId(java.lang.String lifecycleId)
Lifecycle
.
lifecycleId
- the lifecycle-id identifying the Lifecycle
to useprotected void exposeHelpers(javax.servlet.http.HttpServletRequest request) throws java.lang.Exception
Called by
renderMergedOutputModel(Map, HttpServletRequest, HttpServletResponse)
.
The default implementation is empty. This method can be overridden to add
custom helpers as request attributes.
request
- current HTTP request
java.lang.Exception
- if there's a fatal error while we're adding attributesrenderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected java.lang.String prepareViewIdForRendering(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
Lifecycle
.
This implementation simply returns the configured URL. Subclasses can override this to determine a resource to render, typically interpreting the URL in a different manner.
request
- current HTTP requestresponse
- current HTTP response
java.lang.Exception
- if preparations failedAbstractUrlBasedView.getUrl()
protected final void renderMergedOutputModel(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
The first step will be preparing the request: In the JSP case, this would mean setting model objects as request attributes. The second step will be the actual rendering of the view, for example including the JSP via a RequestDispatcher.
renderMergedOutputModel
in class AbstractView
model
- combined output Map (never null
),
with dynamic values taking precedence over static attributesrequest
- current HTTP requestresponse
- current HTTP response
java.lang.Exception
- if rendering failedprotected void exposeViewRootIfNecessary(FacesContext context, java.lang.String viewId)
UIViewRoot
to the given
FacesContext
if necessary. This could be the case if the creation
of the UIViewRoot
is not done yet by another component such as
the NavigationHandler
.
context
- FacesContext
for the current requestviewId
- the prepared view identifier of the view to renderFacesContext.getRenderResponse()
protected void render(FacesContext context)
Lifecycle
.
context
- FacesContext
for the current request
FacesException
- if an exception is thrown during the renderingLifecycle.render(FacesContext)
|
JSF-Spring | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |