Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Taglib Question  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This post may contain a couple of questions, but since they are related I didn't want to start several threads.
I realize that when you write custom tags it would make sense to make them reusable. However, if someone is relativly quick at creating custom tags, how important is reusability when the design goal is to clean up the JSP pages and Servlet for a task that will be performed in several places on the web app in several JSP pages?
Also, is it a bad idea to perform actual Database access inside a custom tag? Or should the data be handed to the tag in after retrieving it from the database?
In my web app I am working on, I have some tasks that I think I would like to pull out of the JSP's and Servlets and put them in some custom tags. And as of right now, they are pretty specific tasks to this web app and I don't see myself immedialty reusing them. In fact, since I will be using this to learn how to write custom tasks, I don't see myself trying too terribly hard to make them reusable at this point in time. I just thought I would mention that as it may affect the response to my questions.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
For myself, I use both tags that I have written that are useful across a wide range of web apps, and tags that are appropriate only to a single app.
bear
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you got 2 clashing principles here:
On the left you have the idea that taglibs should be as generic as possible, on the right the idea that you should not make things generic if there is no need for them.
On the whole I'd say keep the tags simple, you can always abstract things away at a later date.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!