org.springframework.extensions.surf
Interface RequestContext

All Superinterfaces:
Serializable
All Known Subinterfaces:
RenderContext
All Known Implementing Classes:
AbstractRenderContext, AbstractRequestContext, DefaultRenderContext, DefaultRequestContext, ThreadLocalRequestContext, WrappedRenderContext, WrappedRequestContext

public interface RequestContext
extends Serializable

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.

Author:
muzquiano

Field Summary
static String ATTR_REQUEST_CONTEXT
           
static String DEBUG_MODE_VALUE_COMPONENTS
           
static String VALUE_CREDENTIAL_VAULT
           
static String VALUE_HEAD_TAGS
           
static String VALUE_IDENTITY_VAULT
           
 
Method Summary
 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.
 String getFormatId()
          Returns the current format id
 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.
 Model getModel()
          Returns the model.
 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.
 Serializable getParameter(String key)
          Retrieves a parameter from the request context
 Map<String,Serializable> 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.
 javax.servlet.http.HttpServletRequest getRequest()
          Returns the HTTP Servlet Request bound to this request
 Content getRequestContent()
          Returns the body of the incoming POST content This is applicable for multipart form requests
 String getRequestContentType()
          Returns the content type of the incoming request
 String getRequestMethod()
          Returns the method of the incoming request
 Page getRootPage()
          Returns the root page for a site.
 WebFrameworkServiceRegistry getServiceRegistry()
          Returns the Web Framework services registry
 Configuration getSiteConfiguration()
          If the site has a configuration XML, then this will return it
 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()
           
 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.
 Map getViewModel()
          Returns the view model
 String getWebsiteTitle()
          Returns the title of the web site.
 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
 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 setCurrentObject(Resource object)
          Sets the current object
 void setFormatId(String formatId)
          Sets the current format id
 void setModel(Model model)
          Sets the current model
 void setPage(Page page)
          Sets the currently executing page.
 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 setTemplate(TemplateInstance currentTemplate)
          Sets the current executing template.
 void setThemeId(String themeId)
          Sets the current theme id
 void setUri(String uri)
          Sets the currently executing uri.
 void setUser(User user)
          Sets the current user for this request
 void setValue(String key, Serializable value)
          Sets a custom attribute onto the request context
 void setViewModel(Map viewModel)
          Sets the view model
 

Field Detail

VALUE_HEAD_TAGS

static final String VALUE_HEAD_TAGS
See Also:
Constant Field Values

VALUE_CREDENTIAL_VAULT

static final String VALUE_CREDENTIAL_VAULT
See Also:
Constant Field Values

VALUE_IDENTITY_VAULT

static final String VALUE_IDENTITY_VAULT
See Also:
Constant Field Values

DEBUG_MODE_VALUE_COMPONENTS

static final String DEBUG_MODE_VALUE_COMPONENTS
See Also:
Constant Field Values

ATTR_REQUEST_CONTEXT

static final String ATTR_REQUEST_CONTEXT
See Also:
Constant Field Values
Method Detail

getId

String getId()
Each request context instance is stamped with a unique id

Returns:
The id of the request context

getSiteConfiguration

Configuration getSiteConfiguration()
If the site has a configuration XML, then this will return it

Returns:
Configuration instance for the site

getWebsiteTitle

String getWebsiteTitle()
Returns the title of the web site. This is drawn from the site configuration XML if available.

Returns:

getPageTitle

String getPageTitle()
Returns the title of the current page. This is drawn from the current page instance, if set.

Returns:
The title of the current page.

setValue

void setValue(String key,
              Serializable value)
Sets a custom attribute onto the request context

Parameters:
key -
value -

getValue

Serializable getValue(String key)
Retrieves a custom value from the request context

Parameters:
key -
Returns:

removeValue

void removeValue(String key)
Removes a custom value from the request context

Parameters:
key -

hasValue

boolean hasValue(String key)
Returns true if a custom value exists in the request context

Parameters:
key -
Returns:
true if a custom value exists in the request context

getValuesMap

Map<String,Serializable> getValuesMap()
Returns the underlying map of the custom key/values pairs stored on this RequestContext instance. Use with caution!

Returns:
the underlying map of custom key/value pairs.

getParameter

Serializable getParameter(String key)
Retrieves a parameter from the request context

Parameters:
key -
Returns:

hasParameter

boolean hasParameter(String key)
Returns true if a parameter exists in the request context

Parameters:
key -
Returns:
true if a custom value exists in the request context

getParameters

Map<String,Serializable> getParameters()
Returns a map of parameters

Returns:
the underlying map of parameters

setUri

void setUri(String uri)
Sets the currently executing uri.


getUri

String getUri()
Returns:
the currently executing uri.

getPage

Page getPage()
If a page instance is currently executing, it can be retrieved from the request context.

Returns:
The current page

setPage

void setPage(Page page)
Sets the currently executing page.

Parameters:
page -

getPageId

String getPageId()
Returns the id of the currently executing page. If a currently executing page is not set, this will return null.

Returns:
The current page id (or null)

getLinkBuilder

LinkBuilder getLinkBuilder()
Returns the LinkBuilder to be used for the currently executing page. In general, you will have one link builder per site but this hook allows for the possibility of multiple.

Returns:

getRootPage

Page getRootPage()
Returns the root page for a site. A root page is designated if it either has a root-page property in its XML or the site configuration has specifically designated a root page.

Returns:
The root page of the application

getTemplate

TemplateInstance getTemplate()
Returns the current executing template.

Returns:

setTemplate

void setTemplate(TemplateInstance currentTemplate)
Sets the current executing template.


getTemplateId

String getTemplateId()
Returns the id of the currently executing template. If no template is set, this will return null.

Returns:
The current template id or null

getCurrentObjectId

String getCurrentObjectId()
Returns the id of the current object If no object has been set, then the id will be null.

Returns:
The id of the current object

getCurrentObject

Resource getCurrentObject()
Returns the current object If no object has been set, then null is returned

Returns:
The current object

setCurrentObject

void setCurrentObject(Resource object)
Sets the current object

Parameters:
object -

getFormatId

String getFormatId()
Returns the current format id

Returns:

setFormatId

void setFormatId(String formatId)
Sets the current format id

Parameters:
formatId -

getModel

Model getModel()
Returns the model. The model allows object model manipulation and persistence.

Returns:

setModel

void setModel(Model model)
Sets the current model

Parameters:
model -

setUser

void setUser(User user)
Sets the current user for this request

Parameters:
user -

getUser

User getUser()
Returns the current user

Returns:

getUserId

String getUserId()
Returns the current user id

Returns:

getCredentialVault

CredentialVault getCredentialVault()
Returns the credential vault

Returns:

getThemeId

String getThemeId()
Returns the current theme id


setThemeId

void setThemeId(String themeId)
Sets the current theme id


getTheme

Theme getTheme()
Returns:
the current Theme object or null if not set

getRenderingComponents

Component[] getRenderingComponents()
Returns the components that were bound to this and any of its parent context during the rendering. This is useful to determine what other components are configured on the current page. If no rendering components are set, null will be returned

Returns:
An array of Component objects

setRenderingComponent

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.

Parameters:
component - The component that is being rendered

getRequestContentType

String getRequestContentType()
Returns the content type of the incoming request

Returns:
content type

getRequestMethod

String getRequestMethod()
Returns the method of the incoming request

Returns:
request method

getRequestContent

Content getRequestContent()
Returns the body of the incoming POST content This is applicable for multipart form requests

Returns:
content

getRequest

javax.servlet.http.HttpServletRequest getRequest()
Returns the HTTP Servlet Request bound to this request

Returns:

release

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.


getViewModel

Map getViewModel()
Returns the view model

Returns:
map of view model variables keyed by name

setViewModel

void setViewModel(Map viewModel)
Sets the view model

Parameters:
viewModel - map

getServiceRegistry

WebFrameworkServiceRegistry getServiceRegistry()
Returns the Web Framework services registry

Returns:
services registry


Copyright © 2009 SpringSource, Inc. All Rights Reserved.