aspose file tools*
The moose likes JSP and the fly likes TEI TagExtraInfo - Use of? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "TEI TagExtraInfo - Use of?" Watch "TEI TagExtraInfo - Use of?" New topic
Author

TEI TagExtraInfo - Use of?

Nathan Johnson
Ranch Hand

Joined: Feb 18, 2002
Posts: 32
Okay, I have just read up on the TagExtraInfo helper class as used with Tag Libraries. I am afraid the explanation given in the book I am reading is somewhat confusing even after reading it a couple of times.
Would anyone out there be so kind as to explain (in layman's terms) what TEI's are all about and when they should be used?
Thanks very much (in advance!)
Sita Kotamraju
Ranch Hand

Joined: Nov 30, 2001
Posts: 60
TagExtraInfo can be used to
1. Define Scripting Variables.
2. Validation.
example for defining scripting variable:

i dont know how to do validation yet.
Nathan Johnson
Ranch Hand

Joined: Feb 18, 2002
Posts: 32
Thanks Sita!
Shawn Bayern
Author
Ranch Hand

Joined: May 06, 2002
Posts: 160
Originally posted by Sita Kotamraju:

i dont know how to do validation yet.

To do validation, you can override the isValid() method in your subclass of TagExtraInfo (TEI). isValid() accepts a TagData object as its single parameter. For instance, to blindly deny all use of the tag (just as an exercise), you could include the following in your TEI subclass:
public boolean isValid(TagData us) {
return false;
}
TagData has methods like getAttribute(String) that lets you check the (non-rtexprvalue) attributes of the tag's invocation. I often use a utility method, isSpecified(), to determine whether an attribute was specified or not. (For some reason, this is often what I need to validate against -- was attribute X specified without attribute Y also being specified, and so forth.) isSpecified() looks like this:
public static boolean isSpecified(TagData data, String attributeName) {
return (data.getAttribute(attributeName) != null);
}
In general, TEIs are somewhat limited. I recommend JSP 1.2-style TagLibraryValidator (TLV_ classes. While these are somewhat more difficult and tedious to write, they're also much more powerful. (Has anyone here written TLVs? I sometimes feel like I'm the only one.) I included a few instructive examples of TLVs in the JSTL reference-implementation, specifically to encourage their wider adoption. You can see the code at the Jakarta Taglibs CVS archive. There are some clean examples of TEIs there too.
Hope that helps!


Shawn Bayern<br />"JSTL in Action" <a href="http://www.jstlbook.com" target="_blank" rel="nofollow">http://www.jstlbook.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TEI TagExtraInfo - Use of?