Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data sharing between tags....

 
mendy smith
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the different ways of sharing data between tags? which is the best and when will each type be appropriate. could anyone please expand on this topic.
Appreciate u'r feedback,
Thanks.
 
Cynthia Yao
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used two ways.

One is declare pageContext level variables, if the data is shared for several tags, then you have to use it, but the shortcome is that you have to import the necessary library in the jsp. And you also need a extrainfo class to declare it and destroy it in one of tag or declare the variable in the jsp.
the second one is in nested tags, use: findAncestorWithClass
and get the ancestor and get the data out. You will have to declare the tag in the tld file as can contain jsp in it.
here is the official jsp tag tutorial: http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic