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

SimpleTagSupport

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I've had a bit of down time the last couple of days so I started messing around with custom tags because I really never have looked too much into them. Lucky for me the JSP 2.0 spec has SimpleTagSupport to make my life easier. I started out with some simple tags that simply spit out strings and/or some simple HTML and then I decided to create a tag that makes an html SELECT item feeding it attributes for values and items via EL. I was able to accomplish this pretty easily, but I am wondering if I am going about it the right way. Below is my doTag method (stripped down a bit for easy reading)



Now my real code is a bit more complex simply because it iterates over collections of items and values and creates a bunch of OPTION tags. But this gets the point across. Is it common to have to deal with this much printing out of HTML strings in custom tags? Or am I missing something?

Thanks.


GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

If a tag is primarily going to spit out HTML I prefer to use a tag file rather than building up markup in code.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Bear Bibeault:
If a tag is primarily going to spit out HTML I prefer to use a tag file rather than building up markup in code.


That is a good idea Bear. Thanks.
Naveen Mishra
Ranch Hand

Joined: Nov 20, 2005
Posts: 75
Hi Gregg,
I've written the same thing .
In my case , i'm passing a Map object carrying key / value (value/display text) within it .

This is serving great for me.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SimpleTagSupport