public interface RequestContext extends Serializable, org.springframework.extensions.surf.extensibility.HandlesExtensibility
Represents the context of the original request to the web page.
This context object is manufactured at the top of the request chain and is then made available to all templates, regions, components, chrome and anything else downstream.
This object provides a single point of reference for information about the user, the current rendering page and other context. It provides this information so that individual rendering pieces do not need to load it themselves.
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_REQUEST_CONTEXT |
static String |
DEBUG_MODE_VALUE_COMPONENTS |
static String |
USER_ENDPOINT
Request level marker to the factory impl to override the endpoint used to load user
meta-data during the instantiation of the request context.
|
static String |
VALUE_CREDENTIAL_VAULT |
static String |
VALUE_HEAD_TAGS |
static String |
VALUE_IDENTITY_VAULT |
| Modifier and Type | Method and Description |
|---|---|
void |
addCssDependency(String dependency,
String media)
This method allows CSS resources to be added into the same list of dependencies added to by extension
modules.
|
void |
addJSDependency(String dependency)
This method allows JavaScript resources to be added into the same list of dependencies added to by extension
modules.
|
void |
addSubComponentDebugData(String id,
SubComponent.RenderData data)
Adds the
SubComponent.RenderData for the specified SubComponent. |
boolean |
dependencyAlreadyRequested(String dep)
Checks whether or not the supplied dependency has already been requested.
|
Serializable |
getAttribute(String key)
Retrieves an attribute from the request context
|
Map<String,Serializable> |
getAttributes()
Returns a map of attributes
|
String |
getContentAsString()
This method must be implemented to return the result of calling
getContentAsString()
method of the FakeHttpServletResponse that is returned from the getResponse()
method when the RequestContext is in passive mode. |
String |
getContextPath()
Returns the request context path
|
org.springframework.extensions.webscripts.connector.CredentialVault |
getCredentialVault()
Returns the credential vault
|
Resource |
getCurrentObject()
Returns the current object
If no object has been set, then null is returned
|
String |
getCurrentObjectId()
Returns the id of the current object
If no object has been set, then the id will be null.
|
List<ExtensionModule> |
getEvaluatedModules() |
Map<String,Serializable> |
getEvaluatedProperties() |
String |
getExtensionDependencies()
Returns the dependencies requested by extension modules as a formatted String.
|
String |
getFormatId()
Returns the current format id
|
String |
getHeader(String key)
Retrieves an header from the request context
|
Map<String,String> |
getHeaders()
Returns a map of headers
|
String |
getId()
Each request context instance is stamped with a unique id
|
LinkBuilder |
getLinkBuilder()
Returns the LinkBuilder to be used for the currently executing
page.
|
Map<String,Object> |
getModel()
Returns the spring mvc model
|
ModelObjectService |
getObjectService()
Returns the model object service
|
Page |
getPage()
If a page instance is currently executing, it can be retrieved
from the request context.
|
String |
getPageId()
Returns the id of the currently executing page.
|
String |
getPageTitle()
Returns the title of the current page.
|
String |
getParameter(String key)
Retrieves a parameter from the request context
|
Map<String,String> |
getParameters()
Returns a map of parameters
|
Component[] |
getRenderingComponents()
Returns the components that were bound to this and any of its parent context
during the rendering.
|
RenderMode |
getRenderMode()
A
RenderMode can be set by a ComponentTypes to allow different outputs
to be rendered when requesting a Component directly by specifying a "mode" request
parameter. |
org.springframework.extensions.surf.util.Content |
getRequestContent()
Returns the body of the incoming POST content
This is applicable for multipart form requests
|
String |
getRequestMethod()
Returns the method of the incoming request
|
String |
getRequestScheme()
Returns the protocol (e.g.
|
javax.servlet.http.HttpServletResponse |
getResponse()
This method must be implemented to return the
HttpServletResponse associated
with the RequestContext. |
Page |
getRootPage()
Returns the root page for a site.
|
WebFrameworkServiceRegistry |
getServiceRegistry()
Returns the service registry
|
String |
getServletContextPath() |
Configuration |
getSiteConfiguration()
If the site has a configuration XML, then this will return it
|
SubComponent.RenderData |
getSubComponentDebugData(String id)
Retrieves the
SubComponent.RenderData for the specified SubComponent. |
TemplateInstance |
getTemplate()
Returns the current executing template.
|
String |
getTemplateId()
Returns the id of the currently executing template.
|
Theme |
getTheme() |
String |
getThemeId()
Returns the current theme id
|
String |
getUri() |
Map<String,String> |
getUriTokens()
Retrieves any URI tokens parsed in the view resolver.
|
org.springframework.extensions.webscripts.connector.User |
getUser()
Returns the current user
|
String |
getUserId()
Returns the current user id
|
Serializable |
getValue(String key)
Retrieves a custom value from the request context
|
Map<String,Serializable> |
getValuesMap()
Returns the underlying map of the custom key/values pairs
stored on this RequestContext instance.
|
String |
getViewName() |
String |
getWebsiteTitle()
Returns the title of the web site.
|
boolean |
hasAttribute(String key)
Returns true if an attribute exists in the request context
|
boolean |
hasHeader(String key)
Returns true if an header exists in the request context
|
boolean |
hasParameter(String key)
Returns true if a parameter exists in the request context
|
boolean |
hasValue(String key)
Returns true if a custom value exists in the request context
|
boolean |
isPassiveMode()
This method can be used to determine whether or not the
RequestContext is set to
currently run in passive mode. |
void |
markDependencyAsRequested(String dep)
This method can be used to indicate that the supplied dependency has been requested by other means.
|
void |
release()
Release any resources held by the request context
As part of the contract for a RequestContext object, this will only ever be called once
and no further method calls will be made to the RequestContext object.
|
void |
removeValue(String key)
Removes a custom value from the request context
|
void |
setConfigService(org.springframework.extensions.config.ConfigService configService) |
void |
setCurrentObject(Resource object)
Sets the current object
|
void |
setDependencyHandler(DependencyHandler dependencyHandler) |
void |
setEvaluatedProperties(Map<String,Serializable> properties) |
void |
setExtensibilityModuleHandler(ExtensibilityModuleHandler extensibilityModuleHandler) |
void |
setFormatId(String formatId)
Sets the current format id
|
void |
setModel(Map<String,Object> model)
Sets the spring mvc model
|
void |
setPage(Page page)
Sets the currently executing page.
|
void |
setPassiveMode(boolean passiveMode)
This method must be implemented to store whether or not the
RequestContext is being
used in passive mode or not. |
void |
setRenderingComponent(Component component)
Indicates that the given component is being rendered as part of
the rendering execution for this and any parent rendering context.
|
void |
setRenderMode(RenderMode renderMode)
This method can be called to update the
RenderMode used for rendering. |
void |
setResponse(javax.servlet.http.HttpServletResponse response)
This method must be implemented to set the supplied
HttpServletResponse
as the response for the RequestContext. |
void |
setServletContextPath(String path) |
void |
setTemplate(TemplateInstance currentTemplate)
Sets the current executing template.
|
void |
setTheme(Theme theme)
Sets the theme
|
void |
setUri(String uri)
Sets the currently executing uri.
|
void |
setUriTokens(Map<String,String> uriTokens)
Sets the parsed URI tokens
|
void |
setUser(org.springframework.extensions.webscripts.connector.User user)
Sets the current user for this request
|
void |
setValue(String key,
Serializable value)
Sets a custom attribute onto the request context
|
void |
setViewName(String viewName)
Spring MVC view name - generally the same as the page ID but may
be different due to URI template 'pageid' token matching.
|
void |
setWebFrameworkConfigElement(WebFrameworkConfigElement webFrameworkConfigElement) |
addExtensibilityDirectives, addExtensionBundleToCache, closeExtensibilityModel, getCachedExtendedBundle, getCurrentExtensibilityModel, getExtendedScriptConfigModel, getExtendedTemplateConfigModel, getExtendingModuleFiles, getFileBeingProcessed, isExtensibilitySuppressed, openExtensibilityModel, setFileBeingProcessed, updateExtendingModuleDependenciesstatic final String VALUE_HEAD_TAGS
static final String VALUE_CREDENTIAL_VAULT
static final String VALUE_IDENTITY_VAULT
static final String DEBUG_MODE_VALUE_COMPONENTS
static final String ATTR_REQUEST_CONTEXT
static final String USER_ENDPOINT
String getId()
Configuration getSiteConfiguration()
String getWebsiteTitle()
String getPageTitle()
void setValue(String key, Serializable value)
key - Stringvalue - SerializableSerializable getValue(String key)
key - Stringvoid removeValue(String key)
key - Stringboolean hasValue(String key)
key - StringMap<String,Serializable> getValuesMap()
String getParameter(String key)
key - Stringboolean hasParameter(String key)
key - StringMap<String,String> getParameters()
void setUri(String uri)
String getUri()
void setViewName(String viewName)
viewName - Spring MVC view nameString getViewName()
Page getPage()
void setPage(Page page)
page - PageString getPageId()
LinkBuilder getLinkBuilder()
Page getRootPage()
TemplateInstance getTemplate()
void setTemplate(TemplateInstance currentTemplate)
String getTemplateId()
String getCurrentObjectId()
Resource getCurrentObject()
void setCurrentObject(Resource object)
object - ResourceString getFormatId()
void setFormatId(String formatId)
formatId - Stringvoid setUser(org.springframework.extensions.webscripts.connector.User user)
user - Userorg.springframework.extensions.webscripts.connector.User getUser()
String getUserId()
org.springframework.extensions.webscripts.connector.CredentialVault getCredentialVault()
Theme getTheme()
void setTheme(Theme theme)
theme - ThemeString getThemeId()
Component[] getRenderingComponents()
void setRenderingComponent(Component component)
component - The component that is being renderedString getRequestMethod()
org.springframework.extensions.surf.util.Content getRequestContent()
String getRequestScheme()
Returns the protocol (e.g. HTTP/HTTPS) of the request.
void release()
WebFrameworkServiceRegistry getServiceRegistry()
ModelObjectService getObjectService()
String getContextPath()
String getServletContextPath()
void setServletContextPath(String path)
Serializable getAttribute(String key)
key - Stringboolean hasAttribute(String key)
key - StringMap<String,Serializable> getAttributes()
String getHeader(String key)
key - Stringboolean hasHeader(String key)
key - StringMap<String,String> getHeaders()
void setUriTokens(Map<String,String> uriTokens)
uriTokens - MapMap<String,String> getUriTokens()
RenderMode getRenderMode()
A RenderMode can be set by a ComponentTypes to allow different outputs
to be rendered when requesting a Component directly by specifying a "mode" request
parameter. The RenderMode defaults to RenderMode.VIEW but will be set
in the context if the "mode" request parameter is detected when a component is
directly requested to be rendered.
RenderMode for the current context.void setRenderMode(RenderMode renderMode)
This method can be called to update the RenderMode used for rendering.
The RenderMode only affects the rendering of Components. Different
RenderModes can be configured in ComponentType configuration files.
renderMode - RenderModejavax.servlet.http.HttpServletResponse getResponse()
This method must be implemented to return the HttpServletResponse associated
with the RequestContext. However, if the RequestContext has been
set to "passive" (via the setPassiveMode method then this should return a
FakeHttpServletResponse to ensure that rendering isn't output twice as passive
mode is used to calculate dependencies (see
TemplateInstanceRenderer).
HttpServletResponse when isPassiveMode() returns false
and a FakeHttpServletResponse when isPassiveMode() returns true.void setResponse(javax.servlet.http.HttpServletResponse response)
This method must be implemented to set the supplied HttpServletResponse
as the response for the RequestContext. More importantly it should also use
the supplied HttpServletResponse to instantiate and set the FakeHttpServletResponse
to be returned by the .getResponse() method when the RequestContext
has been set to run in passive mode.
response - The HttpServletResponse to associate with the RequestContext.void setPassiveMode(boolean passiveMode)
This method must be implemented to store whether or not the RequestContext is being
used in passive mode or not. Passive mode is used to calculate component dependencies for bound
regions before the templates are executed properly
passiveMode - booleanboolean isPassiveMode()
This method can be used to determine whether or not the RequestContext is set to
currently run in passive mode. Passive mode is used to calculate component dependencies for bound
regions before the templates are executed properly
true if the RequestContext has been set to run in passive mode
and false otherwise.String getContentAsString() throws UnsupportedEncodingException
This method must be implemented to return the result of calling getContentAsString()
method of the FakeHttpServletResponse that is returned from the getResponse()
method when the RequestContext is in passive mode.
UnsupportedEncodingExceptionvoid setExtensibilityModuleHandler(ExtensibilityModuleHandler extensibilityModuleHandler)
void setDependencyHandler(DependencyHandler dependencyHandler)
void setWebFrameworkConfigElement(WebFrameworkConfigElement webFrameworkConfigElement)
void setConfigService(org.springframework.extensions.config.ConfigService configService)
void addJSDependency(String dependency)
This method allows JavaScript resources to be added into the same list of dependencies added to by extension modules. This has only been added as a workaround for the migration of applications from double-pass to single-pass WebScript processing. This allows both WebScripts with and without .head.ftl files to add dependencies.
dependency - The JavaScript resource to add as a dependency.void addCssDependency(String dependency, String media)
This method allows CSS resources to be added into the same list of dependencies added to by extension modules. This has only been added as a workaround for the migration of applications from double-pass to single-pass WebScript processing. This allows both WebScripts with and without .head.ftl files to add dependencies.
dependency - The CSS resource to add as a dependency.String getExtensionDependencies()
Returns the dependencies requested by extension modules as a formatted String. The dependency requests are processed
by the associated DependencyHandler to take advantage of caching and optional checksum identification and
CSS data image generation.
List<ExtensionModule> getEvaluatedModules()
void setEvaluatedProperties(Map<String,Serializable> properties)
Map<String,Serializable> getEvaluatedProperties()
SubComponent.RenderData getSubComponentDebugData(String id)
Retrieves the SubComponent.RenderData for the specified SubComponent. This will contain all the information
about the SubComponentEvaluation that ultimately determined the content of the SubComponent and
the URI, properties, etc. that were used.
id - The identifier of the SubComponent to retrieve the SubComponent.RenderData for.SubComponent.RenderData for the requested SubComponent or null if it could not be found.void addSubComponentDebugData(String id, SubComponent.RenderData data)
Adds the SubComponent.RenderData for the specified SubComponent. This will contain all the information
about the SubComponentEvaluation that ultimately determined the content of the SubComponent and
the URI, properties, etc. that were used.
id - The identifier of the SubComponent to retrieve the SubComponent.RenderData for.data - The SubComponent.RenderData to add.boolean dependencyAlreadyRequested(String dep)
Checks whether or not the supplied dependency has already been requested.
dep - The path to the dependency to check.true if the dependency has already been requested and false otherwise.void markDependencyAsRequested(String dep)
This method can be used to indicate that the supplied dependency has been requested by other means.
This is provided to ensure that dependencies requested directly on the output stream (e.g. via the
JavaScriptDependencyDirective, CssDependencyDirective, etc.)
dep - The path to the dependency to mark as requested.Copyright © 2005–2016 Alfresco Software. All rights reserved.