Package org.opencms.jsp
Class A_CmsJspJsonTag
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
org.opencms.jsp.A_CmsJspJsonTag
- All Implemented Interfaces:
Serializable
,javax.servlet.jsp.tagext.BodyTag
,javax.servlet.jsp.tagext.IterationTag
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.Tag
- Direct Known Subclasses:
CmsJspTagJsonArray
,CmsJspTagJsonObject
,CmsJspTagJsonValue
Abstract superclass that handles the common behavior of the jsonarray/jsonobject/jsonvalue tags.
Each of these tags constructs a JSON value, adds it to the surrounding JSON context object if one exists, and optionally stores the result in a page context variable, either as a JSON object or as formatted JSON text, depending on the value of the mode attribute.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
The key attribute.protected String
The mode attribute.protected String
The scope attribute.protected Object
The target attribute.protected String
The var attribute.Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToTarget
(Object target, Object val, String key) Adds the specified value to the selected target.int
doEndTag()
abstract Object
Returns the JSON value that should be added to the surrounding context and/or stored in the variable given by the var attribute.protected static int
Converts the given string description of a scope to the corresponding PageContext constant.protected void
init()
Initializes / resets the internal values.void
release()
Releases the resources used by this tag.void
Sets the key attribute.void
Sets the mode attribute.void
Sets the scope attribute.void
Sets the target attribute.void
Sets the var attribute.Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, setBodyContent
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
-
Field Details
-
m_key
The key attribute. -
m_mode
The mode attribute. -
m_var
The var attribute. -
m_target
The target attribute. -
m_scope
The scope attribute.
-
-
Constructor Details
-
A_CmsJspJsonTag
public A_CmsJspJsonTag()
-
-
Method Details
-
getScope
Converts the given string description of a scope to the corresponding PageContext constant.- Parameters:
scope
- String description of scope- Returns:
- PageContext constant corresponding to given scope description
-
doEndTag
- Specified by:
doEndTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doEndTag
in classjavax.servlet.jsp.tagext.BodyTagSupport
- Throws:
javax.servlet.jsp.JspException
- See Also:
-
TagSupport.doEndTag()
-
getJsonValue
Returns the JSON value that should be added to the surrounding context and/or stored in the variable given by the var attribute.- Returns:
- the value to add/store
- Throws:
javax.servlet.jsp.JspTagException
- if getting the value fails
-
release
Releases the resources used by this tag.- Specified by:
release
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
release
in classjavax.servlet.jsp.tagext.BodyTagSupport
-
setKey
Sets the key attribute.- Parameters:
key
- the key under which to store the value in the surrounding JSON object
-
setMode
Sets the mode attribute.- Parameters:
mode
- the mode
-
setScope
Sets the scope attribute.- Parameters:
scope
- the variable scope
-
setTarget
Sets the target attribute.- Parameters:
target
- the target Object to store the JSON in. This must be another JSON object or a JSON wrapper.
-
setVar
Sets the var attribute.- Parameters:
var
- the name of the variable to store the result in
-
addToTarget
protected void addToTarget(Object target, Object val, String key) throws javax.servlet.jsp.JspException Adds the specified value to the selected target.- Parameters:
target
- the target objectval
- the value to setkey
- the key to set the value, required in case the target is a JSONObject- Throws:
javax.servlet.jsp.JspException
- in case the value could not be added to the target
-
init
Initializes / resets the internal values.
-