|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.opencms.flex.jsp.CmsJspActionElement
Bean to be used in JSP scriptlet code that provides direct access to the functionality offered by the opencms taglib.
By instanciating a bean of this type and accessing the methods provided by the instance, all functionality of the OpenCms JSP taglib can be easily used from within JSP scriplet code,
Initialize this bean at the beginning of your JSP like this:
<jsp:useBean id="cms" class="com.opencms.flex.jsp.CmsJspActionElement"> <% cms.init(pageContext, request, response); %> </jsp:useBean>All exceptions that occur when calling any method of this class are catched and written to the log output only, so that a template still has a chance of working at last in some elements.
Field Summary | |
static java.lang.String |
C_NOT_INITIALIZED
Error message in case bean was not properly initialized |
Constructor Summary | |
CmsJspActionElement()
Empty constructor, required for every JavaBean. |
|
CmsJspActionElement(javax.servlet.jsp.PageContext context,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Constructor, with parameters. |
Method Summary | |
com.opencms.file.CmsObject |
getCmsObject()
Returns the CmsObject from the wrapped request. |
java.lang.String |
getContent(java.lang.String target)
Returns the processed output of an OpenCms resource in a String. |
boolean |
getHandleExceptions()
Returns true if Exceptions are handled by the class instace, or
false if they will be thrown and have to be handled by the calling class. |
com.opencms.flex.util.CmsMessages |
getMessages(java.lang.String bundleName,
java.lang.String language)
Generates an initialized instance of CmsMessages for
convenient access to localized resource bundles. |
com.opencms.flex.util.CmsMessages |
getMessages(java.lang.String bundleName,
java.lang.String language,
java.lang.String defaultLanguage)
Generates an initialized instance of CmsMessages for
convenient access to localized resource bundles. |
com.opencms.flex.util.CmsMessages |
getMessages(java.lang.String bundleName,
java.lang.String language,
java.lang.String country,
java.lang.String variant,
java.lang.String defaultLanguage)
Generates an initialized instance of CmsMessages for
convenient access to localized resource bundles. |
com.opencms.flex.jsp.CmsJspNavBuilder |
getNavigation()
Returns an initialized CmsJspNavBuilder instance. |
javax.servlet.jsp.PageContext |
getPageContext()
Returns the JSP page context wrapped by this element. |
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the request wrapped by the element. |
com.opencms.file.CmsRequestContext |
getRequestContext()
Returns the current request context from the internal CmsObject. |
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the reponse wrapped by this element. |
void |
include(java.lang.String target)
Include a sub-element without paramters from the OpenCms VFS, same as using the <cms:include file="..." |
void |
include(java.lang.String target,
java.lang.String element)
Include a named sub-element without paramters from the OpenCms VFS, same as using the <cms:include file="..." element="..." |
void |
include(java.lang.String target,
java.lang.String element,
java.util.Map parameterMap)
Include a named sub-element with paramters from the OpenCms VFS, same as using the <cms:include file="..." element="..." |
void |
includeSilent(java.lang.String target,
java.lang.String element)
Includes a named sub-element supressing all Exceptions that occur during the include, otherwise the same as using include(String, String, Map null) . |
void |
includeSilent(java.lang.String target,
java.lang.String element,
java.util.Map parameterMap)
Includes a named sub-element supressing all Exceptions that occur during the include, otherwise the same as using include(String, String, Map) . |
java.lang.String |
info(java.lang.String property)
Returns an OpenCms or JVM system info property value, same as using the <cms:info property="..." |
void |
init(javax.servlet.jsp.PageContext context,
com.opencms.flex.cache.CmsFlexRequest req,
com.opencms.flex.cache.CmsFlexResponse res)
Initialize the bean with the current page context, request and response. |
void |
init(javax.servlet.jsp.PageContext context,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Initialize the bean with the current page context, request and response. |
java.lang.String |
label(java.lang.String label)
Returns an OpenCms workplace label. |
java.lang.String |
link(java.lang.String link)
Calculate a link with the OpenCms link management, same as using the <cms:link>... |
java.util.Map |
properties()
Returns all properites of the current file. |
java.util.Map |
properties(java.lang.String file)
Returns all properites of the selected file. |
java.lang.String |
property(java.lang.String name)
Returns a selected file property value, same as using the <cms:property name="..." |
java.lang.String |
property(java.lang.String name,
java.lang.String file)
Returns a selected file property value, same as using the <cms:property name="..." file="..." |
java.lang.String |
property(java.lang.String name,
java.lang.String file,
java.lang.String defaultValue)
Returns a selected file property value, same as using the <cms:property name="..." file="..." default="..." |
java.lang.String |
property(java.lang.String name,
java.lang.String file,
java.lang.String defaultValue,
boolean escapeHtml)
Returns a selected file property value with optional HTML escaping, same as using the <cms:property name="..." file="..." default="..." |
void |
setHandleExceptions(boolean value)
Controls if Exceptions that occur in methods of this class are supressed (true) or not (false). |
boolean |
template(java.lang.String element)
Checks if a template part should be used or not, same as using the <cms:template element="..." |
java.lang.String |
user(java.lang.String property)
Returns a selected user property, i.e. information about the currently logged in user, same as using the <cms:user property="..." |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String C_NOT_INITIALIZED
Constructor Detail |
public CmsJspActionElement()
public CmsJspActionElement(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
req
- the JSP requestres
- the JSP responseMethod Detail |
public void init(javax.servlet.jsp.PageContext context, com.opencms.flex.cache.CmsFlexRequest req, com.opencms.flex.cache.CmsFlexResponse res)
It is required to call one of the init() methods before you can use the instance of this bean.
req
- the JSP request casted to a CmsFlexRequestres
- the JSP response casted to a CmsFlexResponsepublic void init(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
It is required to call one of the init() methods before you can use the instance of this bean.
req
- the JSP requestres
- the JSP responsepublic boolean getHandleExceptions()
true
if Exceptions are handled by the class instace, or
false
if they will be thrown and have to be handled by the calling class.
The default is true
.
If set to false
Exceptions that occur internally will be wrapped into
a RuntimeException and thrown to the calling class instance.
Important: Exceptions that occur during a call to includeSilent(String, String, Map)
will NOT be handled.
true
if Exceptions are handled by the class instace, or
false
if they will be thrown and have to be handled by the calling classpublic void setHandleExceptions(boolean value)
The default is true
.
If set to false
all Exceptions that occur internally will be wrapped into
a RuntimeException and thrown to the calling class instance.
Important: Exceptions that occur during a call to includeSilent(String, String, Map)
will NOT be handled.
public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.jsp.PageContext getPageContext()
public com.opencms.file.CmsObject getCmsObject()
This is a convenience method in case you need access to the CmsObject in your JSP scriplets.
CmsFlexRequest.getCmsObject()
public void include(java.lang.String target) throws javax.servlet.jsp.JspException
<cms:include file="..." />
tag.
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)
javax.servlet.jsp.JspException
- in case there were problems including the targetCmsJspTagInclude
public void include(java.lang.String target, java.lang.String element) throws javax.servlet.jsp.JspException
<cms:include file="..." element="..." />
tag.
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)element
- the element (template selector) to display from the target
javax.servlet.jsp.JspException
- in case there were problems including the targetCmsJspTagInclude
public void include(java.lang.String target, java.lang.String element, java.util.Map parameterMap) throws javax.servlet.jsp.JspException
<cms:include file="..." element="..." />
tag
with parameters in the tag body.The parameter map should be a map where the keys are Strings (the parameter names) and the values are of type String[]. However, as a convenience feature, in case you provide just a String for the parameter value, it will automatically be translated to a String[1].
The handling of the element
parameter depends on the
included file type. Most often it is used as template selector.
Important: Exceptions that occur in the include process are NOT
handled even if setHandleExceptions(boolean)
was set to true
.
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)element
- the element (template selector) to display from the targetparameterMap
- a map of the request parameters
javax.servlet.jsp.JspException
- in case there were problems including the targetCmsJspTagInclude
public void includeSilent(java.lang.String target, java.lang.String element)
include(String, String, Map null)
.This is a convenience method that allows to include elements on a page without checking if they exist or not. If the target element does not exist, nothing is printed to the JSP output.
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)element
- the element (template selector) to display from the targetpublic void includeSilent(java.lang.String target, java.lang.String element, java.util.Map parameterMap)
include(String, String, Map)
.This is a convenience method that allows to include elements on a page without checking if they exist or not. If the target element does not exist, nothing is printed to the JSP output.
target
- the target uri of the file in the OpenCms VFS (can be relative or absolute)element
- the element (template selector) to display from the targetparameterMap
- a map of the request parameterspublic java.lang.String link(java.lang.String link)
<cms:link>...</cms:link>
tag.This is important to get the right link for exported resources, e.g. for images in the online project.
link
- the uri in the OpenCms to link to
CmsJspTagLink
public java.lang.String user(java.lang.String property)
<cms:user property="..." />
tag.
property
- the user property to display, please see the tag documentation for valid options
CmsJspTagUser
public java.lang.String property(java.lang.String name)
<cms:property name="..." />
tag or
calling property(String name, String null, String null, boolean false)
.
name
- the name of the property to look for
property(String, String, String, boolean)
,
CmsJspTagProperty
public java.lang.String property(java.lang.String name, java.lang.String file)
<cms:property name="..." file="..." />
tag or
calling property(String name, String file, String null, boolean false)
.
name
- the name of the property to look forfile
- the file (or folder) to look at for the property
property(String, String, String, boolean)
,
CmsJspTagProperty
public java.lang.String property(java.lang.String name, java.lang.String file, java.lang.String defaultValue)
<cms:property name="..." file="..." default="..." />
tag or
calling property(String name, String file, String defaultValue, boolean false)
.
name
- the name of the property to look forfile
- the file (or folder) to look at for the propertydefaultValue
- a default value in case the property was not found
property(String, String, String, boolean)
,
CmsJspTagProperty
public java.lang.String property(java.lang.String name, java.lang.String file, java.lang.String defaultValue, boolean escapeHtml)
<cms:property name="..." file="..." default="..." />
tag.
Please see the description of the class CmsJspTagProperty
for
valid options of the file
parameter.
name
- the name of the property to look forfile
- the file (or folder) to look at for the propertydefaultValue
- a default value in case the property was not foundescapeHtml
- if true
, special HTML characters in the return value
are escaped with their number representations (e.g. & becomes &)
CmsJspTagProperty
public java.util.Map properties()
public java.util.Map properties(java.lang.String file)
Please see the description of the class CmsJspTagProperty
for
valid options of the file
parameter.
file
- the file (or folder) to look at for the properties
CmsJspTagProperty
public java.lang.String info(java.lang.String property)
<cms:info property="..." />
tag.
See the description of the class CmsJspTagInfo
for a detailed list
of available options for the property value.
property
- the property to look up
CmsJspTagInfo
public java.lang.String label(java.lang.String label)
You should consider using a standard
java.util.ResourceBundle
instead of the
OpenCms workplace language files.
label
- the label to look up
CmsJspTagLabel
public boolean template(java.lang.String element)
<cms:template element="..." />
tag.
true
if the element is active, false
otherwiseCmsJspTagUser
public com.opencms.file.CmsRequestContext getRequestContext()
public com.opencms.flex.jsp.CmsJspNavBuilder getNavigation()
CmsJspNavBuilder
instance.
CmsJspNavBuilder
CmsJspNavBuilder
public com.opencms.flex.util.CmsMessages getMessages(java.lang.String bundleName, java.lang.String language)
CmsMessages
for
convenient access to localized resource bundles.
bundleName
- the name of the ResourceBundle to uselanguage
- language indentificator for the locale of the bundle
public com.opencms.flex.util.CmsMessages getMessages(java.lang.String bundleName, java.lang.String language, java.lang.String defaultLanguage)
CmsMessages
for
convenient access to localized resource bundles.
bundleName
- the name of the ResourceBundle to uselanguage
- language indentificator for the locale of the bundledefaultLanguage
- default for the language, will be used
if language is null or empty String "", and defaultLanguage is not null
public com.opencms.flex.util.CmsMessages getMessages(java.lang.String bundleName, java.lang.String language, java.lang.String country, java.lang.String variant, java.lang.String defaultLanguage)
CmsMessages
for
convenient access to localized resource bundles.
bundleName
- the name of the ResourceBundle to uselanguage
- language indentificator for the locale of the bundlecountry
- 2 letter country code for the locale of the bundlevariant
- a vendor or browser-specific variant codedefaultLanguage
- default for the language, will be used
if language is null or empty String "", and defaultLanguage is not null
ResourceBundle
,
CmsMessages
public java.lang.String getContent(java.lang.String target)
target
- the target to process
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |