Hans,

Thanks for your help with this. I think its about time I got some new JSP
books that cover JSP 1.2 !

Catharine

----- Original Message -----
From: "Hans Bergsten" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 23, 2002 6:06 PM
Subject: Re: TEI classes for custom tags


> cbarnes wrote:
> > I am writing a number of custom tags, all of which return a list of
string
> > values to the JSP by using a TEI class.
> > I want to write a generic TEI class that can be used by all the custom
tags.
> > This TEI class needs to be supplied with a list of attribute names that
it
> > has to create VariableInfo objects for. The tag classes have this list
of
> > attribute names as a tag attribute, so I thought that I could get this
list
> > from the TagData object in the TEI class by doing something like:
> > Vector listOfAttributes = (Vector)data.getAttribute("attributeNames");
> >
> > However, this doesn't appear to work. I get a ClassCastException trying
to
> > cast the object to a Vector.
>
> The Object returned by getAttribute() is either a String or the special
> Object instance named REQUEST_TIME_VALUE, to tell the TEI that the
> attribute is defined by a request-time attribute expression and can
> not be evaluated at translation time. So if you specify a list of names
> as a tag attribute, you have to use getAttributeString(), or cast the
> returned value from getAttribute() to a String, and then parse the
> list yourself. Something like this:
>
>    String varNames = data.getAttributeString("varNames");
>    StringTokenizer st = new StringTokenizer(varNames, ",");
>
> > Can anyone tell me if its possible to get this to work?
> >
> > Is there a better way of supplying a list of attribute names to the TEI
> > class.
> >
> > Am I going to have to give in and write a different TEI class for each
of
> > the custom tags?
>
> If you use a web container that supports JSP 1.2 (most of the recent
> ones do), you can avoid writing TEI classes altogether and declare
> the variables to create in the TLD instead:
>
>    <tag>
>      <name>myTag</name>
>      <tag-class>com.mycompany.MyTag</tag-class>
>      <variable>
>        <name-from-attribute>id</name-from-attribute>
>        <variable-class>java.lang.String</variable-class>
>        <declare>true</declare>
>        <scope>AT_END</scope>
>      </variable>
>      ...
>    </tag>
>
> JSP 1.2 has many other nice features, for instance a new IterationTag
> interface for tag handlers that loop over their bodies but do not
> need to read the body content (like you asked about in another mail).
> Here's a couple of articles that describes the new features:
>
>    <http://www.onjava.com/pub/a/onjava/2001/10/10/jsp.html>
>    <http://www.onjava.com/pub/a/onjava/2001/11/07/jsp12.html>
>
> Hans
> --
> Hans Bergsten           [EMAIL PROTECTED]
> Gefion Software         http://www.gefionsoftware.com
> JavaServer Pages        http://TheJSPBook.com
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to