• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tag calss  RSS feed

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
People,
I have a working jsp which I am trying to split using custom tags. Each related functionality goes into a tag.
This is kind of basic... I have a method which is called by only one tag class. Can I write this method in that custom tag class? I mean can a tag class have methods other than doStartTag and doEndTag methods? Why not?

This is kind of urgent so please do respond ASAP.
Thanks in advance..
Vasu
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should not have any problem doing this.
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't have actually..
Thanks,
vasu
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually you have to be very careful. You can create instance methods in your tag handler without problems. What you can't do is to assume that you can manipulate the attribute values set by the container as you wish.
For a question that is so urgent, you're being a bit light on the details of what you are having a problem with.
hrh,
bear
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
What you can't do is to assume that you can manipulate the attribute values set by the container as you wish.

What do you mean by that
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container assumes that it is the only entity setting values for the attributes. if you muck around with them internal to the tag, you can get some very undesirable behavior.
Let's say for example, that you have two references to a custom tag in a row that specify the same value for an attribute. On the second reference to the tag, the container may very well NOT call the setter because it knows that it already called it with the proper value for the first reference. If you've changed the value internally, you'll be scratching your head for some time trying to figure out why the value is wrong.
It can get even more hairy if you have optional attributes.
So bascially, it's hands off the attribute values.
hth,
bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!