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
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_TAGFields inherited from interface jakarta.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAINFields inherited from interface jakarta.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintdoEndTag()voidintjakarta.servlet.jsp.tagext.TaggetParse()Gets the JSON string to be parsed instead of using the body of the tag.getScope()Gets the scope where the variable will be stored.getVar()Gets the variable name where the parsed JSON will be stored.voidrelease()voidsetBodyContent(jakarta.servlet.jsp.tagext.BodyContent content) voidsetPageContext(jakarta.servlet.jsp.PageContext context) voidsetParent(jakarta.servlet.jsp.tagext.Tag tag) voidSets a JSON string to be parsed instead of using the contents of the tag body.voidSets the scope where the variable will be stored.voidSets the variable name where the parsed JSON will be stored.
-
Constructor Details
-
JSONTag
public JSONTag()
-
-
Method Details
-
getVar
Gets the variable name where the parsed JSON will be stored.- Returns:
- The variable.
-
setVar
Sets the variable name where the parsed JSON will be stored.- Parameters:
variable- The variable name
-
getParse
Gets the JSON string to be parsed instead of using the body of the tag.- Returns:
- the json string
-
setParse
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
Gets the scope where the variable will be stored.- Returns:
- The scope name.
-
setScope
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:
setPageContextin interfacejakarta.servlet.jsp.tagext.Tag
-
setParent
public void setParent(jakarta.servlet.jsp.tagext.Tag tag) - Specified by:
setParentin interfacejakarta.servlet.jsp.tagext.Tag
-
getParent
public jakarta.servlet.jsp.tagext.Tag getParent()- Specified by:
getParentin interfacejakarta.servlet.jsp.tagext.Tag
-
doStartTag
public int doStartTag() throws jakarta.servlet.jsp.JspException- Specified by:
doStartTagin interfacejakarta.servlet.jsp.tagext.Tag- Throws:
jakarta.servlet.jsp.JspException
-
doEndTag
public int doEndTag() throws jakarta.servlet.jsp.JspException- Specified by:
doEndTagin interfacejakarta.servlet.jsp.tagext.Tag- Throws:
jakarta.servlet.jsp.JspException
-
release
public void release()- Specified by:
releasein interfacejakarta.servlet.jsp.tagext.Tag
-
setBodyContent
public void setBodyContent(jakarta.servlet.jsp.tagext.BodyContent content) - Specified by:
setBodyContentin interfacejakarta.servlet.jsp.tagext.BodyTag
-
doInitBody
public void doInitBody() throws jakarta.servlet.jsp.JspException- Specified by:
doInitBodyin interfacejakarta.servlet.jsp.tagext.BodyTag- Throws:
jakarta.servlet.jsp.JspException
-
doAfterBody
public int doAfterBody() throws jakarta.servlet.jsp.JspException- Specified by:
doAfterBodyin interfacejakarta.servlet.jsp.tagext.IterationTag- Throws:
jakarta.servlet.jsp.JspException
-