Class A_CmsJspJsonTag

  • All Implemented Interfaces:
    java.io.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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String m_key
      The key attribute.
      protected java.lang.String m_mode
      The mode attribute.
      protected java.lang.String m_scope
      The scope attribute.
      protected java.lang.Object m_target
      The target attribute.
      protected java.lang.String m_var
      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
      A_CmsJspJsonTag()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addToTarget​(java.lang.Object target, java.lang.Object val, java.lang.String key)
      Adds the specified value to the selected target.
      int doEndTag()  
      abstract java.lang.Object getJsonValue()
      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 getScope​(java.lang.String scope)
      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 setKey​(java.lang.String key)
      Sets the key attribute.
      void setMode​(java.lang.String mode)
      Sets the mode attribute.
      void setScope​(java.lang.String scope)
      Sets the scope attribute.
      void setTarget​(java.lang.Object target)
      Sets the target attribute.
      void setVar​(java.lang.String var)
      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 Detail

      • m_key

        protected java.lang.String m_key
        The key attribute.
      • m_mode

        protected java.lang.String m_mode
        The mode attribute.
      • m_var

        protected java.lang.String m_var
        The var attribute.
      • m_target

        protected java.lang.Object m_target
        The target attribute.
      • m_scope

        protected java.lang.String m_scope
        The scope attribute.
    • Method Detail

      • getScope

        protected static int getScope​(java.lang.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 java.lang.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​(java.lang.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​(java.lang.String mode)
        Sets the mode attribute.
        Parameters:
        mode - the mode
      • setScope

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

        public void setTarget​(java.lang.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​(java.lang.String var)
        Sets the var attribute.
        Parameters:
        var - the name of the variable to store the result in
      • addToTarget

        protected void addToTarget​(java.lang.Object target,
                                   java.lang.Object val,
                                   java.lang.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.