|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BodyTag
BodyTag lets tags access the generated tag contents and it allows tag looping. For example, a SQL tag may use the enclosed SQL to update a table. A BodyTag must explicitly write the contents the enclosing stream.
if (tag.doStartTag() == EVAL_BODY_TAG) { out = pageContext.pushBody(); tag.setBodyContent(out); tag.doInitBody(); do { ... } while (tag.doAfterBody() == EVAL_BODY_AGAIN); out = pageContent.popBody(); } if (tag.doEndTag() == SKIP_PAGE) return;
Field Summary | |
---|---|
static int |
EVAL_BODY_BUFFERED
Constant returned by doStartTag to evaluate a tag body. |
static int |
EVAL_BODY_TAG
Deprecated. |
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 |
Method Summary | |
---|---|
int |
doAfterBody()
Tags call doAfterBody after processing the tag body. |
void |
doInitBody()
Tags call doInitBody before processing the tag body. |
void |
setBodyContent(BodyContent out)
Sets the BodyContent stream. |
Methods inherited from interface javax.servlet.jsp.tagext.Tag |
---|
doEndTag, doStartTag, getParent, release, setPageContext, setParent |
Field Detail |
---|
static final int EVAL_BODY_TAG
static final int EVAL_BODY_BUFFERED
Method Detail |
---|
void setBodyContent(BodyContent out)
out
- The body content for tag and its contents.void doInitBody() throws JspException
empty tags and tags returning SKIP_BODY do not call doInitBody and doAfterBody.
if (tag.doStartTag() == EVAL_BODY_TAG) {
out = pageContext.pushBody();
tag.setBodyContent(out);
tag.doInitBody();
...
}
JspException
int doAfterBody() throws JspException
empty tags and tags returning SKIP_BODY do not call doInitBody and doAfterBody.
Here's an example of a tag that copies its contents to the output (assuming setBodyContent sets bodyOut):
public int doAfterBody() throws JspException
{
try {
bodyOut.writeOut(bodyOut.getEnclosingWriter());
} catch (IOException e) {
throw JspException(String.valueOf(e));
}
return SKIP_PAGE;
}
doAfterBody
in interface IterationTag
JspException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |