Package org.opencms.loader
Interface I_CmsTemplateContextProvider
-
- All Known Implementing Classes:
CmsDefaultTemplateContextProvider
public interface I_CmsTemplateContextProvider
Interface for template context providers.Implementations of this class are used to dynamically determine a template used for rendering a page at runtime, e.g. there could be one template for desktop browsers and another for mobile browsers. It is possible to override the template using a cookie containing the name of the template context which should be used as a value. The cookie name is determined by the template context provider.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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
getEditorStyleSheet(CmsObject cms, java.lang.String editedResourcePath)
Returns the style sheet to be used for the editor.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, java.lang.String config)
Initializes the context provider using a CMS object.java.lang.String
readCommonProperty(CmsObject cms, java.lang.String propertyName, java.lang.String fallbackValue)
Gets the value which should be used instead of a property which was read from the template resource.
-
-
-
Method Detail
-
getAllContexts
java.util.Map<java.lang.String,CmsTemplateContext> getAllContexts()
Gets a map of all template contexts, with the template context names as keys.- Returns:
- the map of template context providers
-
getEditorStyleSheet
java.lang.String getEditorStyleSheet(CmsObject cms, java.lang.String editedResourcePath)
Returns the style sheet to be used for the editor.- Parameters:
cms
- the current CMS contexteditedResourcePath
- the path of the edited resource- Returns:
- the path of the style sheet to be used for the resource
-
getOverrideCookieName
java.lang.String getOverrideCookieName()
Gets the name of the cookie which should be used for overriding the template context.- Returns:
- the name of the cookie used for overriding the template context
-
getTemplateContext
CmsTemplateContext getTemplateContext(CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
Determines the template context from the current CMS context, request, and resource.- Parameters:
cms
- the CMS contextrequest
- the current requestresource
- the resource being rendered- Returns:
- the current template context
-
initialize
void initialize(CmsObject cms, java.lang.String config)
Initializes the context provider using a CMS object.- Parameters:
cms
- the current CMS contextconfig
- the template context provider configuration
-
readCommonProperty
java.lang.String readCommonProperty(CmsObject cms, java.lang.String propertyName, java.lang.String fallbackValue) throws CmsException
Gets the value which should be used instead of a property which was read from the template resource.This is needed because before template context providers, it was common to store template-specific configuration in a property on the template JSP. Since template context providers make the result ambiguous, this method is intended as a replacement.
- Parameters:
cms
- the CMS context to usepropertyName
- the name of the propertyfallbackValue
- the value to return if no value is found or an error occurs- Returns:
- the common property value
- Throws:
CmsException
- if something goes wrong
-
-