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

public abstract class A_CmsJspJsonTag extends javax.servlet.jsp.tagext.BodyTagSupport
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

    Fields
    Modifier and Type
    Field
    Description
    protected 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addToTarget(Object target, Object val, String key)
    Adds the specified value to the selected target.
    int
     
    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
    Initializes / resets the internal values.
    void
    Releases the resources used by this tag.
    void
    Sets the key attribute.
    void
    Sets the mode attribute.
    void
    Sets the scope attribute.
    void
    setTarget(Object target)
    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

  • Constructor Details

  • Method Details

    • getScope

      protected static int getScope(String scope)
      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

      public int doEndTag() throws javax.servlet.jsp.JspException
      Specified by:
      doEndTag in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
      Throws:
      javax.servlet.jsp.JspException
      See Also:
      • TagSupport.doEndTag()
    • getJsonValue

      public abstract Object getJsonValue() throws javax.servlet.jsp.JspTagException
      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

      public void release()
      Releases the resources used by this tag.

      Specified by:
      release in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      release in class javax.servlet.jsp.tagext.BodyTagSupport
    • setKey

      public void setKey(String key)
      Sets the key attribute.
      Parameters:
      key - the key under which to store the value in the surrounding JSON object
    • setMode

      public void setMode(String mode)
      Sets the mode attribute.
      Parameters:
      mode - the mode
    • setScope

      public void setScope(String scope)
      Sets the scope attribute.
      Parameters:
      scope - the variable scope
    • setTarget

      public void setTarget(Object target)
      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

      public void setVar(String var)
      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 object
      val - the value to set
      key - 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

      protected void init()
      Initializes / resets the internal values.