• 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

default value for a custom tag attribute

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a custom tag attribute, how do we specify a default value? Is it in the TLD file?
Thx in advance
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As definition in the JSP DTD file:
<!ELEMENT attribute (name, required? rtexprvalue? type?, description?) >
There is no place in the TLD file for you to define the default value for an attribute. However you can specify the "required" field of an attribute as "false", which marks it as optional. Then in your tabclass, define the default value for that attribute. If later when using the tag in your JSP, you specified an attribute value, the JSP container will overwrite the default value by calling the setter method in your tagclass.
Does that make sense?
Tieyi
 
Shreyas Reddy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Thanks
 
Shreyas Reddy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey by the way where did you get this from?

<!ELEMENT attribute (name, required? rtexprvalue? type?, description?) >


I was looking at the JSP 1.1 specs. I didn't find the type and description elements for an attribute element in the dtd.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic