• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you create your tag libraries?

 
C Kutler
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out how to set up my dev environment. If you build your own tag libraries, I have some questions for you.
Do you build the tag libraries according to some specs and deliver them to page designers (or yourself), or do you build the JSP pages and tag library simultaneously, on an as needed basis?
Do you tend to create the tag libraries as a separate Java project or do you usually build them in a web project?
Do you create the tag library from Java classes or from tag files, or do you have tag libraries that have both types?
Have you ever generated tags on the fly by cutting code from your JSP file and sticking it in a tag file?
How do you decide whether to implement as a tag file or a JSP segment?
Where do you put the TLD files?
How do you share the tag libraries with co-workers? What do you do about version control and distributing changes?
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you build the tag libraries according to some specs and deliver them to page designers (or yourself), or do you build the JSP pages and tag library simultaneously, on an as needed basis?
Yes. (In other words, all of the above).
Do you tend to create the tag libraries as a separate Java project or do you usually build them in a web project?
Yes. (In other words, both. It depends).
Do you create the tag library from Java classes or from tag files, or do you have tag libraries that have both types?
Both.
Have you ever generated tags on the fly by cutting code from your JSP file and sticking it in a tag file?
No, I don't put code in my JSPs.
How do you decide whether to implement as a tag file or a JSP segment?
Favor tag files where appropriate.
Where do you put the TLD files?
Either under WEB-INF/ if the tag library is non-jarred, or in the jar file's META-INF folder.
How do you share the tag libraries with co-workers? What do you do about version control and distributing changes?
Use source control as well as versioning for tag libraries that are implemented as separate projects in jar files.
 
C Kutler
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,
Thanks for your helpful answers. If you don't mind I have some more questions.
1. Do you put your tlds in WEB-INF/ or WEB-INF/tlds? I see examples doing it both ways and don't know which is better.
2. About this question and answer:
Have you ever generated tags on the fly by cutting code from your JSP file and sticking it in a tag file?
No, I don't put code in my JSPs.

I don't think I phrased the question correctly. I probably shouldn't have said "code". I was thinking more along the line of finding myself repeating the same set of JSP elements or EL over and over and deciding to use a tag file or fragment instead. I was wondering about such ad-hoc work. Would it be correct to create a WEB-INF/tags/util dir and start moving this stuff to tag files in that directory?
I guess I should probably just jump in and get my feet wet. However, I find that getting the right set up in the beginning saves work down the line.
3. Which is a better way to point to tag files, and why?

Or add an entry to a TLD and use that uri:

Thanks again for your advice,
CK
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your helpful answers. If you don't mind I have some more questions.
My pleasure.
Do you put your tlds in WEB-INF/ or WEB-INF/tlds? I see examples doing it both ways and don't know which is better.
Actually, I usually create a folder named WEB-INF/config where I put various config files, which include those tld files that are not stored in jar files.
I was wondering about such ad-hoc work. Would it be correct to create a WEB-INF/tags/util dir and start moving this stuff to tag files in that directory?
Ah, yes. While I have a boat-load of custom action libraries ("custom actions" being the new, en-vogue term for custom tags) that I use across all my web apps, each web app usually ends up with a set of app-specific tags and tag files, some of which are factored out of the JSP pages as I code them. I'm actually at the point where I can anticipate what will end up a tag -- and create the tag or tag file up front -- but I will still come across stuff that tends to get repeated and will factor it out as described.
Which is a better way to point to tag files, and why?
The only significant difference I can think of is that if you go the tld route, you can assign a common prefix to a set of tags regardless of whether they are Java or tag file based.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!