• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BodyTagSupport doesn't output body

 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

Below is the complete code for a BodyTag class I have created.



I then call the tag with a body. But the body is never output.

What additional methods must I implement in order to simply output the body WITHOUT changing the return type of doStartTag()? In other words, in what BodyTag method do I actually output the body?

(Yes, I know I could return EVAL_BODY_INCLUDE to output the body. But I am trying to understand the methods of BodyTag better.)

Thanks!
John
 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This may help you

same doubt asked
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key thing you're forgetting is to write the buffered body content to the output! So you need to add either the doAfterBody() or doEndTag() methods like this:
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you both.

But I still have a question. In your book, Charles, on page 399 you say "Be default, therefore, all BodyTagSupport subclasses evaluate the body once only uising the BodyContent buffer and continue evaluation of the calli9ng JSP once doEndTag() returns".

So, do understand correctly that the body in my above sample is EVALUATED, but never OUTPUT? (And if so I wonder of what use that could ever be.)

Happy holidays,
John
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, do understand correctly that the body in my above sample is EVALUATED, but never OUTPUT? (And if so I wonder of what use that could ever be.)
Yes, that's correct (but I didn't design the API, so can't comment on the use of it!).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic