Getting started with custom tags

Source: Internet
Author: User

 

BodyTagSupport execution sequence

Methods for loading the BodyTagSupport class:

When writing the implementation class corresponding to the label, you need to reload several methods of the BodyTagSupport class: doStartTag (), setBodyContent (), doInitBody (), doAfterBody (), doEndTag ();

 

Their execution order is as follows:

DoStartTag () → doInitBody () → setBodyContent () → doAfterBody () → doEndTag ()

 

 

The doStartTag () method returns EVAL_BODY_INCLUDE or SKIP_BODY,

If EVAL_BODY_INCLUDE is returned, the execution continues;

If SKIP_BODY is returned, the following doInitBody (), setBodyContent (), and doAfterBody () methods will not be executed,

Directly execute the doEndTag () method.

 

The setBodyContent () method is used to set the content of the TAG body. If Initialization is required before this, it is completed in the doInitBody () method.

After the label body content is executed, the doAfterBody () method is called. This method returns EVAL_BODY_TAG, SKIP_BODY,

EVAL_PAGE or SKIP_PAGE.

If EVAL_BODY_TAG is returned, the TAG body is set again until SKIP_BODY is returned;

If EVAL_PAGE is returned, the following parts of the JSP page will be executed after the label body is executed;

If SKIP_PAGE is returned, the subsequent content of the JSP page will not be executed.

 

Static constants in the Tag:

 

EVAL_BODY_INCLUDE: tells the server body content and sends the content to the output stream.

SKIP_BODY: tells the server not to process the body content

EVAL_PAGE: allows the server to continue executing the page

SKIP_PAGE: prevents the server from processing the remaining page

EVAL_BODY_AGAIN: Let the server continue to process the body content. Only the doAfterBody method can return

EVAL_BODY_BUFFERED: Field of the BodyTag interface, which is returned in doStartTag ().

EVAL_BODY_INCLUDE and SKIP_BODY are generally returned by doStartTag (), while EVAL_PAPGE and SKIP_PAGE are returned by doEndTag ().


From the path of the mouse programmer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.