• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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.
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic