Class JSONTag

java.lang.Object
com.invirgance.convirgance.web.tag.JSONTag
All Implemented Interfaces:
jakarta.servlet.jsp.tagext.BodyTag, jakarta.servlet.jsp.tagext.IterationTag, jakarta.servlet.jsp.tagext.JspTag, jakarta.servlet.jsp.tagext.Tag

public class JSONTag extends Object implements jakarta.servlet.jsp.tagext.BodyTag
A custom JSP tag that parses JSON content and makes it available as a variable. This tag processes its body content as JSON text, parses it into a Java object structure using JSONParser, and makes the resulting object available as a page variable or passes it to a parent tag that implements ValueTypeTag.
Author:
jbanes
  • Field Summary

    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
     
    int
     
    void
     
    int
     
    jakarta.servlet.jsp.tagext.Tag
     
    Gets the JSON string to be parsed instead of using the body of the tag.
    Gets the scope where the variable will be stored.
    Gets the variable name where the parsed JSON will be stored.
    void
     
    void
    setBodyContent(jakarta.servlet.jsp.tagext.BodyContent content)
     
    void
    setPageContext(jakarta.servlet.jsp.PageContext context)
     
    void
    setParent(jakarta.servlet.jsp.tagext.Tag tag)
     
    void
    Sets a JSON string to be parsed instead of using the contents of the tag body.
    void
    Sets the scope where the variable will be stored.
    void
    setVar(String variable)
    Sets the variable name where the parsed JSON will be stored.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JSONTag

      public JSONTag()
  • Method Details

    • getVar

      public String getVar()
      Gets the variable name where the parsed JSON will be stored.
      Returns:
      The variable.
    • setVar

      public void setVar(String variable)
      Sets the variable name where the parsed JSON will be stored.
      Parameters:
      variable - The variable name
    • getParse

      public String getParse()
      Gets the JSON string to be parsed instead of using the body of the tag.
      Returns:
      the json string
    • setParse

      public void setParse(String parse)
      Sets a JSON string to be parsed instead of using the contents of the tag body. This is useful when a data record contains a JSON string which needs to be parsed as the body only allows static JSON.
      Parameters:
      parse - the json string to parse
    • getScope

      public String getScope()
      Gets the scope where the variable will be stored.
      Returns:
      The scope name.
    • setScope

      public void setScope(String scope)
      Sets the scope where the variable will be stored. Valid options are: page, request, session, application.
      Parameters:
      scope - The scope name.
    • setPageContext

      public void setPageContext(jakarta.servlet.jsp.PageContext context)
      Specified by:
      setPageContext in interface jakarta.servlet.jsp.tagext.Tag
    • setParent

      public void setParent(jakarta.servlet.jsp.tagext.Tag tag)
      Specified by:
      setParent in interface jakarta.servlet.jsp.tagext.Tag
    • getParent

      public jakarta.servlet.jsp.tagext.Tag getParent()
      Specified by:
      getParent in interface jakarta.servlet.jsp.tagext.Tag
    • doStartTag

      public int doStartTag() throws jakarta.servlet.jsp.JspException
      Specified by:
      doStartTag in interface jakarta.servlet.jsp.tagext.Tag
      Throws:
      jakarta.servlet.jsp.JspException
    • doEndTag

      public int doEndTag() throws jakarta.servlet.jsp.JspException
      Specified by:
      doEndTag in interface jakarta.servlet.jsp.tagext.Tag
      Throws:
      jakarta.servlet.jsp.JspException
    • release

      public void release()
      Specified by:
      release in interface jakarta.servlet.jsp.tagext.Tag
    • setBodyContent

      public void setBodyContent(jakarta.servlet.jsp.tagext.BodyContent content)
      Specified by:
      setBodyContent in interface jakarta.servlet.jsp.tagext.BodyTag
    • doInitBody

      public void doInitBody() throws jakarta.servlet.jsp.JspException
      Specified by:
      doInitBody in interface jakarta.servlet.jsp.tagext.BodyTag
      Throws:
      jakarta.servlet.jsp.JspException
    • doAfterBody

      public int doAfterBody() throws jakarta.servlet.jsp.JspException
      Specified by:
      doAfterBody in interface jakarta.servlet.jsp.tagext.IterationTag
      Throws:
      jakarta.servlet.jsp.JspException