org.opencms.jsp.util
Class CmsJspStandardContextBean

java.lang.Object
  extended by org.opencms.jsp.util.CmsJspStandardContextBean

public final class CmsJspStandardContextBean
extends Object

Allows convenient access to the most important OpenCms functions on a JSP page, indented to be used from a JSP with the JSTL or EL.

This bean is available by default in the context of an OpenCms managed JSP.

Since:
8.0

Field Summary
static String ATTRIBUTE_CMS_OBJECT
          The attribute name of the cms object.
static String ATTRIBUTE_NAME
          The attribute name of the standard JSP context bean.
protected static org.apache.commons.logging.Log LOG
          The logger instance for this class.
protected  CmsObject m_cms
          OpenCms user context.
 
Method Summary
 CmsJspStandardContextBean createCopy()
          Returns a copy of this JSP context bean.
 String elementCachingHash()
          Returns a caching hash specific to the element, it's properties and the current container width.
 CmsContainerBean getContainer()
          Returns the container the currently rendered element is part of.
 CmsResource getDetailContent()
          Returns the current detail content, or null if no detail content is requested.
 CmsUUID getDetailContentId()
          Returns the structure id of the current detail content, or null if no detail content is requested.
 String getDetailContentSitePath()
          Returns the detail content site path.
 CmsContainerElementBean getElement()
          Returns the currently rendered element.
 Object getFunction()
          Returns a map which allows access to dynamic function beans using the JSP EL.
 Map<String,String> getFunctionDetail()
          Returns a lazy map which computes the detail page link as a value when given the name of a (named) dynamic function as a key.
 Map<CmsJspContentAccessBean,CmsDynamicFunctionFormatWrapper> getFunctionFormatFromContent()
          Returns a lazy map which creates a wrapper object for a dynamic function format when given an XML content as a key.
static CmsJspStandardContextBean getInstance(javax.servlet.ServletRequest req)
          Creates a new instance of the standard JSP context bean.
 Locale getLocale()
          Returns the current locale.
 CmsContainerPageBean getPage()
          Returns the currently displayed container page.
 CmsRequestContext getRequestContext()
          Returns the request context.
 String getSubSitePath()
          Returns the subsite path for the currently requested URI.
 CmsJspVfsAccessBean getVfs()
          Returns an initialized VFS access bean.
 Locale getWorkplaceLocale()
          Returns the workplace locale from the current user's settings.
 boolean isDetailPageAvailable()
          Checks whether a detail page is available for the container element.
 boolean isDetailRequest()
          Returns true if this is a request to a detail resource, false otherwise.
 boolean isEdited()
          Returns the flag to indicate if in drag and drop mode.
protected  CmsDynamicFunctionBean readDynamicFunctionBean(String configuredName)
          Reads a dynamic function bean, given its name in the module configuration.
 void setContainer(CmsContainerBean container)
          Sets the container the currently rendered element is part of.
 void setEdited(boolean edited)
          Sets the flag to indicate if in drag and drop mode.
 void setElement(CmsContainerElementBean element)
          Sets the currently rendered element.
 void setPage(CmsContainerPageBean page)
          Sets the currently displayed container page.
 void updateCmsObject(CmsObject cms)
          Updates the internally stored OpenCms user context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_CMS_OBJECT

public static final String ATTRIBUTE_CMS_OBJECT
The attribute name of the cms object.

See Also:
Constant Field Values

ATTRIBUTE_NAME

public static final String ATTRIBUTE_NAME
The attribute name of the standard JSP context bean.

See Also:
Constant Field Values

LOG

protected static final org.apache.commons.logging.Log LOG
The logger instance for this class.


m_cms

protected CmsObject m_cms
OpenCms user context.

Method Detail

getInstance

public static CmsJspStandardContextBean getInstance(javax.servlet.ServletRequest req)
Creates a new instance of the standard JSP context bean.

To prevent multiple creations of the bean during a request, the OpenCms request context attributes are used to cache the created VFS access utility bean.

Parameters:
req - the current servlet request
Returns:
a new instance of the standard JSP context bean

createCopy

public CmsJspStandardContextBean createCopy()
Returns a copy of this JSP context bean.

Returns:
a copy of this JSP context bean

elementCachingHash

public String elementCachingHash()
Returns a caching hash specific to the element, it's properties and the current container width.

Returns:
the caching hash

getContainer

public CmsContainerBean getContainer()
Returns the container the currently rendered element is part of.

Returns:
the currently the currently rendered element is part of

getDetailContent

public CmsResource getDetailContent()
Returns the current detail content, or null if no detail content is requested.

Returns:
the current detail content, or null if no detail content is requested.


getDetailContentId

public CmsUUID getDetailContentId()
Returns the structure id of the current detail content, or null if no detail content is requested.

Returns:
the structure id of the current detail content, or null if no detail content is requested.


getDetailContentSitePath

public String getDetailContentSitePath()
Returns the detail content site path. Returns null if not available.

Returns:
the detail content site path

getElement

public CmsContainerElementBean getElement()
Returns the currently rendered element.

Returns:
the currently rendered element

getFunction

public Object getFunction()
Returns a map which allows access to dynamic function beans using the JSP EL.

When given a key, the returned map will look up the corresponding dynamic function in the module configuration.

Returns:
a map which allows access to dynamic function beans

getFunctionDetail

public Map<String,String> getFunctionDetail()
Returns a lazy map which computes the detail page link as a value when given the name of a (named) dynamic function as a key.

Returns:
a lazy map for computing function detail page links

getFunctionFormatFromContent

public Map<CmsJspContentAccessBean,CmsDynamicFunctionFormatWrapper> getFunctionFormatFromContent()
Returns a lazy map which creates a wrapper object for a dynamic function format when given an XML content as a key.

Returns:
a lazy map for accessing function formats for a content

getLocale

public Locale getLocale()
Returns the current locale.

Returns:
the current locale

getPage

public CmsContainerPageBean getPage()
Returns the currently displayed container page.

Returns:
the currently displayed container page

getRequestContext

public CmsRequestContext getRequestContext()
Returns the request context.

Returns:
the request context

getSubSitePath

public String getSubSitePath()
Returns the subsite path for the currently requested URI.

Returns:
the subsite path

getVfs

public CmsJspVfsAccessBean getVfs()
Returns an initialized VFS access bean.

Returns:
an initialized VFS access bean

getWorkplaceLocale

public Locale getWorkplaceLocale()
Returns the workplace locale from the current user's settings.

Returns:
returns the workplace locale from the current user's settings

isDetailPageAvailable

public boolean isDetailPageAvailable()
Checks whether a detail page is available for the container element.

Returns:
true if there is a detail page for the container element

isDetailRequest

public boolean isDetailRequest()
Returns true if this is a request to a detail resource, false otherwise.

Same as to check if getDetailContent() is null.

Returns:
true if this is a request to a detail resource, false otherwise

isEdited

public boolean isEdited()
Returns the flag to indicate if in drag and drop mode.

Returns:
true if in drag and drop mode

setContainer

public void setContainer(CmsContainerBean container)
Sets the container the currently rendered element is part of.

Parameters:
container - the container the currently rendered element is part of

setEdited

public void setEdited(boolean edited)
Sets the flag to indicate if in drag and drop mode.

Parameters:
edited - true if in drag and drop mode

setElement

public void setElement(CmsContainerElementBean element)
Sets the currently rendered element.

Parameters:
element - the currently rendered element to set

setPage

public void setPage(CmsContainerPageBean page)
Sets the currently displayed container page.

Parameters:
page - the currently displayed container page to set

updateCmsObject

public void updateCmsObject(CmsObject cms)
Updates the internally stored OpenCms user context.

Parameters:
cms - the new OpenCms user context

readDynamicFunctionBean

protected CmsDynamicFunctionBean readDynamicFunctionBean(String configuredName)
                                                  throws CmsException
Reads a dynamic function bean, given its name in the module configuration.

Parameters:
configuredName - the name of the dynamic function in the module configuration
Returns:
the dynamic function bean for the dynamic function configured under that name
Throws:
CmsException - if something goes wrong