• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom JSP Tag - Unrequired-Fields not cleared

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

i wrote a custom tag which builds a specific link. Following attributes



The label attribute is not required.

If label is unspecified:



For the first tag of the JSP everything is working, well. But if i use the Tag a second time and the label attribute is again not used in the jsp -> label has the old value from the last tag! Why?

My workaround is to reset all fields at the end of tag execution. Do somebody know a better solution?

Thanks, Jeff



 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stupid question: is anything in your tag class static?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some containers may cache tags, too.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the entire tag handler. Be sure to use code tags.
 
Jeff Schramm
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Some containers may cache tags, too.



I`m using Tomcat 5.5 -

TagHandler:


TLD:


JSP:


If i comment out


the field 'label' will not be cleared for the second iteration!

thanks for your help,
Jeff
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not have to look far to see a problem.

if(label == null)
label = value;



You are modifying an instance variable from within the tag. That's a no no.

The instance variables that represent attribute values can only be set by the container. You muck with them under the covers, and all hell breaks loose.
 
Jeff Schramm
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I did not have to look far to see a problem.

if(label == null)
label = value;



You are modifying an instance variable from within the tag. That's a no no.

The instance variables that represent attribute values can only be set by the container. You muck with them under the covers, and all hell breaks loose.



thank you for your advise- i will change it tomorrow
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is one of the reasons that Simple Tag handling was introduced in JSP 2.0 -- Classic Tag handling has a lot of "rules" that are easy to fall afoul of.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic