File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes default value for a custom tag attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "default value for a custom tag attribute" Watch "default value for a custom tag attribute" New topic
Author

default value for a custom tag attribute

Shreyas Reddy
Ranch Hand

Joined: Oct 09, 2003
Posts: 49
For a custom tag attribute, how do we specify a default value? Is it in the TLD file?
Thx in advance
Tieyi Guo
Greenhorn

Joined: Oct 29, 2001
Posts: 15
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

Joined: Oct 09, 2003
Posts: 49
Yes. Thanks
Shreyas Reddy
Ranch Hand

Joined: Oct 09, 2003
Posts: 49
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: default value for a custom tag attribute