Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Custom tag question:

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My tag handler class:


My view.jsp:

My TLD:


My question:
How come in doAfterBody(), second line, getBodyContent() returns null?

Thanks!
Jenny
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jenny!
You should return EVAL_BODY_BUFFERED instead of EVAL_BODY_INCLUDE.
Hope it helps.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Osama! It's so cool. It worked after I did what you said.

But... I'm confused... when doStartTag() returns EVAL_BODY_INCLUDE, doesn't the control go to evaluate body? why do I have to have EVAL_BODY_BUFFERED? I don't have setBodyContent() or doInitBody() defined.

Thanks!
Jenny
 
Osama Hasan
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jenny!
BodyContent is available only when the body is buffered. Thus, when we return EVAL_BODY_INCLUDE from doStartTag() the body is not buffered and hence BodyContent is not available.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh thanks, Osama! I didn't know that.

BTW, can I implement the body iteration by using TagSupport?
 
Osama Hasan
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The TagSupport class implements the IterationTag interface. So, you certainly can.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Osama,

I tried to extend TagSupport, but couldn't compile. getBodyContent() is not recognized. How do I get body content then?

Thanks!
Jenny
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to find out...if getBodyContent() method belongs to BodyTagSupport class.

That can be the only reason.
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic