tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: Using scripting variables in a custom taglib
Date Tue, 14 Jan 2003 18:40:52 GMT
Patrick van Kann wrote:
> My apologies if this is not the right list for this question.

I've seen general tag library questions like this on the list before,
so it may be okay. But this list is really intended just for questions
about the libraries that are part of the Taglibs project. General
questions are probably better posted in Sun's JSP forum:

   <http://forum.java.sun.com/forum.jsp?forum=45>

> I have written a JSP 1.2 compliant tag-libary that has nested and
> co-operating tags (it performs OQL queries using Castor as a back-end).
> 
> At the moment, I do not make use of either <variable> elements in my
> descriptor, or JSP 1.1 "tag extra info" classes.
> 
> I suspect that I should be using the <variable> tag, yet all works fine.
> My tags communicate happily using pageContext.setAttribute("myId", obj)
> and pageContext.getAttribute("myId"). Within my JSP pages, I can access
> variables defined in the tag using ${index}.

There's nothing wrong with that; in fact. I would say that it's now the
recommended way of exposing data from a custom tag. A TEI or <variable>
elements is needed only if you want to make it easy to read the data
from scripting code. But if it's rarely needed, I prefer skipping
variable declarations and tell users to use <jsp:useBean> to create
a scripting variable reference to the data instead.

> My question is where can I find a lucid demonstration of how to use the
> <variable> element correctly, or a detailed description/specification of
> how it should be used. Or even better, a book I could buy written by
> someone on this list!

Since you ask :-) My JSP book covers all of this; the recommendation
above plus how to declare variables when you really want to:

   <http://TheJSPBook.com/>

Hans
-- 
Hans Bergsten                                <hans@gefionsoftware.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message