• 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

TEI TagExtraInfo - Use of?

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!)
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sita!
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Your buns are mine! But you can have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic