• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom tags and body processing

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a custom tag, by implementing BodyTag and Serializable. The doStartTag always returns EVAL_BODY_INCLUDE.
According to JSP 1.2 API, the BodyTag interface, the doInitBody() method:

Prepare for evaluation of the body. This method is invoked by the JSP page implementation object after setBodyContent and before the first time the body is to be evaluated. This method will not be invoked for empty tags or for non-empty tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE.


In spite of this, the doInitBody() method is invoked.
Has anyone else encountered this behaviour (tomcat 4.0.1)?
Does anyone else think the taglib api and design is more complex than it need be? I used ATG Dynamo for some time and they implemented the "Droplet" system whereby custom tags were esentially implemented mini servlets. One of the key benefits was that you could pass chunks of dynamic content as parameters - and choose to output them or not. This would be equivalent to having multiple bodies in a custom tag. I can tell you it was a lot simpler than this rigmarole!
Regards
James
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do agree with you in that the tag stuff does seem fairly complicated, although much of it has been down to the lack of in-depth documentation. After all, the specs are great but not the best thing to learn from.
From when tags were introduced a couple of years back, I think the hardest bits to understand were the specifics around BodyTags, and how the BodyContent objects are used and can be nested/stacked. They are an incredibly powerful, yet underused feature.
Just my 2 pennies worth...
Cheers
Simon
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi - Go over to the SCWCD forum and do a search for:
EVAL_BODY_BUFFERED
You will find a lot of information relating to this and custom tags in general.
I personally think that TC 4.01 has some anomolies about the return codes from doStartBody.
I also think this is in general the kind of thing you see when you implement a design using return codes rather than something more robust (like exceptions).
Regards, Guy
 
Create symphonies in seed and soil. For this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic