This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Return values of classic tag  RSS feed

 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

In HFSJ page 595 Q10 says,

doAfterBody() is only called when doStartTag() returns EVAL_BODY_INCLUDE

But even doStartTag() return SKIP_BODY isnt doAfterBody() evaluate?

Secondly in Q9,

Given the following tag <mytags:mytag>BodyContent</mytags:mytag>

It says we have to put EVAL_BODY_INCLUDE in doStart() for out put "BodyContent". But what if we put EVAL_BODY_BUFFERED. It says "it directs the body of the tag to a buffer which this tag does not process" I cant understand the above statement. i mean purpose having BodyTagSupport class is for access the body contents know?

Some one please explain.

Thank You.
 
Mateus Lucio
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harshana, here my understanding:

When you return SKIP_BODY you're saying that the tag doesn't have a body, so there's no point in running doAfterBody() method, when you return EVAL_BODY_INCLUDE you are saying to your tag process the body (and implicity saying that you tag has a body, it may be empty but it's still a body) so it makes sense to call doAfterBody() method.

About the statement
"it directs the body of the tag to a buffer which this tag does not process" I believe the book means the example tag doesn't process the body you could write one that does.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!