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
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
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