• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic attributes and classic tags

 
Stu Johns
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As classic tags are re-used by the container is it required to clear the map of dynamic attributes as part of initiliaing class members in doStartTag?

thanks

Stu
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My immediate thought was you probably will have to, and a Map.clear() would do the job. Then I realised that you'll always be supplying the same dynamic attributes to the tag! For example, if I declare:where both attributes are dynamic, then on each invocation of that handler I'll be replacing the dynamic attributes "dyn1" and "dyn2" by new values, so they'll completely override the existing contents of any storage Map. Although dynamic attributes aren't declared explicitly in the TLD (that's the whole point), they are still statically declared in the JSP page, so they will always be overridden. "Dynamic" is a misnomer here.

I guess the next question is if I have:will those tag instances be re-used together, so will the second tag invocation see the "dyn1" attribute from the first? I think that's probably container dependent, but I would guess not because of the possible problems it would lead to. However, you can always try that in your container and look at the translated JSP code before compilation (on Tomcat, in subdirectories of work/); it should then be easy to see if it reuses the same handler instance or not.
 
Stu Johns
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks,
tomcat does seem to clear the dynamic attributes Map for me, but to be sure I'll do it in doStartTag anyways.

Stu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic