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

TagSupport class defines xxxValues ?

 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like there is a mechanism to support key - value pairs (something like a Map) in the TagSupport class. I assume its like xxxAttribute() kinda framework.
Anyone know what/where these are used for?
I mean in practice/production?
- satya...........trying to put learning into real world apps!
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
satya - Well, I'm one of those people who like to read code.
In TC 4.01 it's a HashTable, declared private, in TagSupport. The getValue, getValues, removeValue, setValue public methods are not used by local code. BodyTagSupport does not call any of these methods either.
So .... it seems like a built-in lookup mechanism for any user tag handler code to use. I sure don't see any doc's on this anywhere 'tho. Also, why no mechanism to 'getKeys'?
Later, Guy
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure either....haven't seen much discussion on this.
- satya
 
Dani Mazzuca
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The TagSupport setValue(), getValue(), etc. methods are intended to be used for nested cooperating tags, to share some dynamically created objects. The enclosing tag creates an objects an puts it using setValue(). The object is available to all inner tag handlers through the use of ((TagSupport)getParent()).getValue(name). It is the same as using pageContext.getAttribute() or pageContext.setAttribute(), however, in this case it uses a private namespace for the nested tags handlers, instead of a common general one.

See “Cooperating Tags” in the J2ee tutorial http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPAdvanced8.html

Dani
 
Ramana Kumar Atmakuru
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
it is really good question.
we can use map interface in situations like where in we have to store indices too.
for example a[]={2,3,4,5,5}; we can use some variable 'i' as an index to retrieve value from the data structure ...here we are not storing indices..
but what if we want set our own index and different index some thing more understandle to retrieve data from the data struture.
for example
a[father]= 50;
a[mother]= 45;
a[son]= 35;
a[dog]= 30;
in the above data struture,,,we have control over index.
actually the above specified example is not correct in any language but for the purpose of understanding how map actually works,i gave that example.
one example..like dictionary
a[obsolete]= old;
we can use in such sort of situations.
hope i have given convincing answer to your question.
good luck guys.
 
Ken Januski
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link Dani. That small page was chockfull of information!!
 
Louise Haydu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of the earlier responses, the following statement was made:
In TC 4.01 it's a HashTable, declared private, in TagSupport. The getValue, getValues, removeValue, setValue public methods are not used by local code. BodyTagSupport does not call any of these methods either.

I thought that BodyTagSupport would be able to call these methods because it is extended from TagSupport. Also, the JavaDocs for BodyTagSupport show these methods as available to BodyTagSupport throught inheritance.
Can anyone clarify this point?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic