• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

default value for a custom tag attribute

 
Shreyas Reddy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • 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
 
Tieyi Guo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Yes. Thanks
 
Shreyas Reddy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic