This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "TEI TagExtraInfo - Use of?" Watch "TEI TagExtraInfo - Use of?" New topic

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
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="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: TEI TagExtraInfo - Use of?
Similar Threads
Tell me why this exception is coming
MessageTei error
No JSP Line number available error when deploying struts on Eclipse editor
set the custom tag variable
Could not load TagExtraInfo class