• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rule of Thumb: TagLib vs Bean

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had previously asked about when to use scriplets and when to use servlets.
Now I am wondering if there is a rule of thumb as to when it is better to use a Custom Tag over a Bean or vice versa.
Also, does a Tag Library hold it's values for the entire session or is it just for the instance of a particular page that is using the Tag Library? The answer to this question could very well answer my first question I suppose.
Thanks.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put a lot of work into this topic for my book and luckily (depending how you see it!), that chapter that talks about all of this is available to download from here.
To summarise - beans for data, tags for actions. Of course, the chapter goes into much more detail than this, explaining the reasoning behind this rule of thumb and taking things like the tag lifecycle and the way that the container uses tags and beans into account.
Hope it's useful!
Simon
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link Simon.
"...we'll look at the frequently asked question of rather to use JavaBeans or custom tags to encapsulate serverside functionallity...."
PERFECT!!
Just was I was looking for.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon, the chapter you gave me the link for cleared up just about every concern I had over when to use Tags and when to use JavaBeans. Then at the end, you eluded to some things in Chapter 9 that I am very interested in learning.
So now, off to buy your book!!
Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!