org.opencms.loader
Class CmsDefaultTemplateContextProvider

java.lang.Object
  extended by org.opencms.loader.CmsDefaultTemplateContextProvider
All Implemented Interfaces:
I_CmsTemplateContextProvider

public class CmsDefaultTemplateContextProvider
extends java.lang.Object
implements I_CmsTemplateContextProvider

Example implementation of a template context provider for deciding between a desktop template and a mobile template.

The template JSP paths are read from a file "templatecontext.properties" in the classpath.


Constructor Summary
CmsDefaultTemplateContextProvider()
          Default constructor.
 
Method Summary
 java.util.Map<java.lang.String,CmsTemplateContext> getAllContexts()
          Gets a map of all template contexts, with the template context names as keys.
 java.lang.String getConfigurationPropertyPath()
          Returns the absolute VFS path, where the configuration property file is stored.
 java.lang.String getEditorStyleSheet(CmsObject cms, java.lang.String editedResourcePath)
          Returns the style sheet to be used for the editor.
 CmsMessageContainer getMessageContainerDesktop()
          Returns the message container.
 CmsMessageContainer getMessageContainerMobile()
          Returns the message container.
 java.lang.String getOverrideCookieName()
          Gets the name of the cookie which should be used for overriding the template context.
 CmsTemplateContext getTemplateContext(CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
          Determines the template context from the current CMS context, request, and resource.
 void initialize(CmsObject cms)
          Initializes the context provider using a CMS object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsDefaultTemplateContextProvider

public CmsDefaultTemplateContextProvider()
Default constructor.

Method Detail

getAllContexts

public java.util.Map<java.lang.String,CmsTemplateContext> getAllContexts()
Description copied from interface: I_CmsTemplateContextProvider
Gets a map of all template contexts, with the template context names as keys.

Specified by:
getAllContexts in interface I_CmsTemplateContextProvider
Returns:
the map of template context providers
See Also:
I_CmsTemplateContextProvider.getAllContexts()

getConfigurationPropertyPath

public java.lang.String getConfigurationPropertyPath()
Returns the absolute VFS path, where the configuration property file is stored.

The configuration property file must have the following format:

By default this method returns null what will trigger the default behavior:
looking for a java property file named 'templatecontext.properties' in the class path.

Extends this class, override this method and return the absolute VFS path where OpenCms should lookup the property file, in order to configure the template JSP inside OpenCms.

Returns:
the absolute VFS path, where the configuration property file is stored

getEditorStyleSheet

public java.lang.String getEditorStyleSheet(CmsObject cms,
                                            java.lang.String editedResourcePath)
Description copied from interface: I_CmsTemplateContextProvider
Returns the style sheet to be used for the editor.

Specified by:
getEditorStyleSheet in interface I_CmsTemplateContextProvider
Parameters:
cms - the current CMS context
editedResourcePath - the path of the edited resource
Returns:
the path of the style sheet to be used for the resource
See Also:
I_CmsTemplateContextProvider.getEditorStyleSheet(org.opencms.file.CmsObject, java.lang.String)

getMessageContainerDesktop

public CmsMessageContainer getMessageContainerDesktop()
Returns the message container.

Returns:
the message container

getMessageContainerMobile

public CmsMessageContainer getMessageContainerMobile()
Returns the message container.

Returns:
the message container

getOverrideCookieName

public java.lang.String getOverrideCookieName()
Description copied from interface: I_CmsTemplateContextProvider
Gets the name of the cookie which should be used for overriding the template context.

Specified by:
getOverrideCookieName in interface I_CmsTemplateContextProvider
Returns:
the name of the cookie used for overriding the template context
See Also:
I_CmsTemplateContextProvider.getOverrideCookieName()

getTemplateContext

public CmsTemplateContext getTemplateContext(CmsObject cms,
                                             javax.servlet.http.HttpServletRequest request,
                                             CmsResource resource)
Description copied from interface: I_CmsTemplateContextProvider
Determines the template context from the current CMS context, request, and resource.

Specified by:
getTemplateContext in interface I_CmsTemplateContextProvider
Parameters:
cms - the CMS context
request - the current request
resource - the resource being rendered
Returns:
the current template context
See Also:
I_CmsTemplateContextProvider.getTemplateContext(org.opencms.file.CmsObject, javax.servlet.http.HttpServletRequest, org.opencms.file.CmsResource)

initialize

public void initialize(CmsObject cms)
Description copied from interface: I_CmsTemplateContextProvider
Initializes the context provider using a CMS object.

Specified by:
initialize in interface I_CmsTemplateContextProvider
Parameters:
cms - the current CMS context
See Also:
I_CmsTemplateContextProvider.initialize(org.opencms.file.CmsObject)