Class ExtendJavascriptVarTag

java.lang.Object
jakarta.servlet.jsp.tagext.TagSupport
jakarta.servlet.jsp.tagext.BodyTagSupport
com.randomnoun.common.webapp.taglib.ExtendJavascriptVarTag
All Implemented Interfaces:
jakarta.servlet.jsp.tagext.BodyTag, jakarta.servlet.jsp.tagext.IterationTag, jakarta.servlet.jsp.tagext.JspTag, jakarta.servlet.jsp.tagext.Tag, Serializable

public class ExtendJavascriptVarTag extends jakarta.servlet.jsp.tagext.BodyTagSupport
Extends a javascript variable with a server-side resource or request attribute. The variable may contain any amount of maps or lists, which will be converted into the javascript equivalent.

Attributes defined for this tag (in common.tld) are:

  • baseName - the name of the javascript variable to extend
  • name - the name of the object within base (may contain sub-object names separated by '.')
  • value - the value of the javascript variable.
  • key - if defined, the value of this field within the value object is used to extend the base object. if key is supplied the object is replaced, not merged

Both name and value may contain EL-style expressions.

Author:
knoxg
See Also:
  • Field Summary

    Fields inherited from class jakarta.servlet.jsp.tagext.BodyTagSupport

    bodyContent

    Fields inherited from class jakarta.servlet.jsp.tagext.TagSupport

    id, pageContext

    Fields inherited from interface jakarta.servlet.jsp.tagext.BodyTag

    EVAL_BODY_BUFFERED, EVAL_BODY_TAG

    Fields inherited from interface jakarta.servlet.jsp.tagext.IterationTag

    EVAL_BODY_AGAIN

    Fields inherited from interface jakarta.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
    int
    doEnd tag handler required to fulfill the Tag interface defined in the JSP specification.
    int
    doStart tag handler required to fulfill the Tag interface defined in the JSP specification.
    Gets the name of the javascript object to modify
    Gets the JSON format (e.g.
    Gets the name of the field within the object to modify
    Gets the name of the javascript variable to generate
    Returns the object to convert into javascript
    void
    setBaseName(String baseName)
    Sets the name of the javascript object to modify
    void
    setJsonFormat(String jsonFormat)
    Sets the JSON format (e.g.
    void
    Sets the name of the field within the object to modify
    void
    Sets the name of the javascript variable to generate
    void
    Sets the object to convert into javascript

    Methods inherited from class jakarta.servlet.jsp.tagext.BodyTagSupport

    doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent

    Methods inherited from class jakarta.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 jakarta.servlet.jsp.tagext.Tag

    getParent, setPageContext, setParent
  • Constructor Details

  • Method Details

    • setBaseName

      public void setBaseName(String baseName)
      Sets the name of the javascript object to modify
      Parameters:
      baseName - the name of the javascript object to modify
    • getBaseName

      public String getBaseName()
      Gets the name of the javascript object to modify
      Returns:
      the name of the javascript object to modify
    • setKey

      public void setKey(String key)
      Sets the name of the field within the object to modify
      Parameters:
      key - the name of the field within the object to modify
    • getKey

      public String getKey()
      Gets the name of the field within the object to modify
      Returns:
      the name of the field within the object to modify
    • setName

      public void setName(String name)
      Sets the name of the javascript variable to generate
      Parameters:
      name - the name of the javascript variable to generate
    • getName

      public String getName()
      Gets the name of the javascript variable to generate
      Returns:
      the name of the javascript variable to generate
    • setValue

      public void setValue(Object value)
      Sets the object to convert into javascript
      Parameters:
      value - the object to convert into javascript
    • getValue

      public Object getValue()
      Returns the object to convert into javascript
      Returns:
      the object to convert into javascript
    • setJsonFormat

      public void setJsonFormat(String jsonFormat)
      Sets the JSON format (e.g. method in which dates are serialised to JSON)
      Parameters:
      name - the JSON format
    • getJsonFormat

      Gets the JSON format (e.g. method in which dates are serialised to JSON)
      Returns:
      the JSON format
    • doStartTag

      public int doStartTag() throws jakarta.servlet.jsp.JspException
      doStart tag handler required to fulfill the Tag interface defined in the JSP specification. This tag is always empty, and therefore must always return BodyTag.SKIP_BODY
      Specified by:
      doStartTag in interface jakarta.servlet.jsp.tagext.Tag
      Overrides:
      doStartTag in class jakarta.servlet.jsp.tagext.BodyTagSupport
      Returns:
      BodyTag.SKIP_BODY
      Throws:
      jakarta.servlet.jsp.JspException
    • doEndTag

      public int doEndTag() throws jakarta.servlet.jsp.JspException
      doEnd tag handler required to fulfill the Tag interface defined in the JSP specification.

      This method does nothing, and always returns BodyTag.EVAL_PAGE

      Specified by:
      doEndTag in interface jakarta.servlet.jsp.tagext.Tag
      Overrides:
      doEndTag in class jakarta.servlet.jsp.tagext.BodyTagSupport
      Returns:
      BodyTag.EVAL_PAGE
      Throws:
      jakarta.servlet.jsp.JspException