aspose file tools*
The moose likes JSP and the fly likes Custom tags and body processing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom tags and body processing" Watch "Custom tags and body processing" New topic
Author

Custom tags and body processing

James Moore
Greenhorn

Joined: Mar 08, 2002
Posts: 6
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
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom tags and body processing