It's not a secret anymore!*
The moose likes JSP and the fly likes How to Write Such a Custom Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to Write Such a Custom Tag" Watch "How to Write Such a Custom Tag" New topic
Author

How to Write Such a Custom Tag

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
I want to use SimpleTagSupport to write a custom tag which is like this:

<my:Menu>
<my:MenuItem ../>
<my:MenuItem ../>
text here should not be rendered
<my:Menu>

In body of <my:Menu>, the only content should be nested tag defining the items to be included in this menu. Any text that caller put inside the body of the <my:Menu> should be ignored.

In the doTag() of my SimpleTagSupport, if I do not include "getJspBody().invoke(null)", the body is not evaluated and the child tag handler for <my:MenuItem ../> will not be invoked. But, if I do include "getJspBody().invoke(null)", the text along side the <my:MenuItem ../> would be displayed!! So how should I write my doTag()??
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Try in tld specify <bodycontent>JSP</bodycontent>


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Write Such a Custom Tag
 
Similar Threads
How to Write This Tag Handler
custom tag using SimpleTagSupport
How do you say to skip body from Simple Tags
Writing My Tag Handler by SimpleTagSupport
Doubt in Simple and classic tags