Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 52592 invoked from network); 12 Sep 2002 18:24:34 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Sep 2002 18:24:34 -0000 Received: (qmail 29872 invoked by uid 97); 12 Sep 2002 18:24:48 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 29854 invoked by uid 97); 12 Sep 2002 18:24:47 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 29829 invoked by uid 98); 12 Sep 2002 18:24:47 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <3D80DBCA.5070008@xmission.com> Date: Thu, 12 Sep 2002 12:24:10 -0600 From: Nic Holbrook User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tomcat Users List Subject: Re: registering variables References: <70DD0724686ED611ACC70050228A1ECA06DC6A@SRV_1> <1031845426.1327.40.camel@desenv1.ritterdosreis.br> X-MIMETrack: Itemize by SMTP Server on jadmin1/Flyingj(Release 5.0.8 |June 18, 2001) at 09/12/2002 12:23:49 PM, Serialize by Router on jadmin1/Flyingj(Release 5.0.8 |June 18, 2001) at 09/12/2002 12:23:50 PM, Serialize complete at 09/12/2002 12:23:50 PM Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Yes, this can be done. Tag example import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; public class Dummy extends BodyTagSupport { protected String name; protected boolean result; public Dummy() { initValues(); } public void release() { initValues(); } private void initValues() { name = ""; result = false; } public void setResult(boolean result) { this.result = result; } public boolean getResult() { return result; } public void setName(String p1) { name = p1; } public String getName() { return name; } public int doStartTag() throws JspTagException { pageContext.setAttribute(name, new Boolean(result)); return(BodyTag.EVAL_BODY_BUFFERED); } } Example Tag Extra Info import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; public class DummyExtraInfo extends TagExtraInfo { public static final String ATTRIB_NAME = "name"; public static final String ATTRIB_TYPE = "java.lang.Boolean"; public VariableInfo[] getVariableInfo(TagData data) { if(data.getAttributeString(ATTRIB_NAME) != null) { VariableInfo info = new VariableInfo(data.getAttributeString(ATTRIB_NAME), ATTRIB_TYPE, true, VariableInfo.AT_BEGIN); return new VariableInfo[] { info }; } else { return new VariableInfo[] {}; } } } Hope this is what you were looking for. Later Nic Felipe Schnack wrote: > Well, actually I'm talking about the TagExtraInfo. With it, you can >register variables in the tag scope... I would like to dinamically >create these variables. > I will not enter in details of why I want to do that, but it's >relative to data access... > It's possible or not? Maybe I can make a TagExtraInfo that grabs data >from it related tag? That's possible? I mean, you have an >"DoSomethingTag" and a "DoSomethingExtraInfoTag". It's possible to >"DoSomethingExtraInfoTag" access ""DoSomethingTag" data? > >On Thu, 2002-09-12 at 12:36, Andreas Mohrig wrote: > > >>I don't know Struts, but if it is possible to register variables in other >>scopes with the help of Struts it gives me the creeps/makes me shudder and >>would not shine a good light on Java as a programming language. Why should >>you want to register a variable in the first place? Java is good for >>encapsulation and information hiding. Data transport can be managed via >>return values of method calls or if there is absolutely no other way over >>global contexts (which is frightful by itself). What you are talking about >>would undermine the foundations of the Java programming language (in my >>humble opinion as a programmer). But I'm willing to learn and to broaden my >>perspective, so if you have a case where it is absolutely necessary (or even >>practically/elegant or otherwise useful) to do what you want to do, please >>let me know about it. >> >>Andreas Mohrig >> >>-----Original Message----- >>From: Felipe Schnack [mailto:felipes@ritterdosreis.br] >>Sent: Thursday, September 12, 2002 5:16 PM >>To: Tomcat Users List >>Subject: RE: registering variables >> >> >> Ok, but this is an attribute, not an variable really. There isn't a >>way I can register a variable? Like in Strut's TE tags? >> >>On Thu, 2002-09-12 at 11:57, Andreas Mohrig wrote: >> >> >>>You could put it in the pageContext (or even in the session or application >>>context). That will require some syntactic clutter (first >>> pageContext.setAttribute("variableName",objectVariable); >>> then (in the jsp page) >>> ObjectType myVariable = >>>(ObjectType)pageContext.getAttribute("variableName",objectVariable); >>>) >>>and opens the possibilitie of errors that are hard to debug (what if there >>>is already an attribute with that name?) but is much safer than directly >>>creating variables in other scopes. It is one of javas merits that this is >>>not possible (at least not to my knowledge). >>> >>>greetings >>> >>>Andreas Mohrig >>> >>>-----Original Message----- >>>From: Felipe Schnack [mailto:felipes@ritterdosreis.br] >>>Sent: Thursday, September 12, 2002 4:42 PM >>>To: Tomcat Users List >>>Subject: registering variables >>> >>> >>> How can I create an variable within an taglib? I would like to be able >>>to create an variable accesible to my jsp page. >>> >>>-- >>> >>>Felipe Schnack >>>Analista de Sistemas >>>felipes@ritterdosreis.br >>>Cel.: (51)91287530 >>>Linux Counter #281893 >>> >>>Faculdade Ritter dos Reis >>>www.ritterdosreis.br >>>felipes@ritterdosreis.br >>>Fone/Fax.: (51)32303328 >>> >>> >>>-- >>>To unsubscribe, e-mail: >>> >>>For additional commands, e-mail: >>> >>> >>>-- >>>To unsubscribe, e-mail: >>> >>> >> >> >> >>>For additional commands, e-mail: >>> >>> >> >> >> >>-- >> >>Felipe Schnack >>Analista de Sistemas >>felipes@ritterdosreis.br >>Cel.: (51)91287530 >>Linux Counter #281893 >> >>Faculdade Ritter dos Reis >>www.ritterdosreis.br >>felipes@ritterdosreis.br >>Fone/Fax.: (51)32303328 >> >> >>-- >>To unsubscribe, e-mail: >> >>For additional commands, e-mail: >> >> >>-- >>To unsubscribe, e-mail: >>For additional commands, e-mail: >> >> >> -- To unsubscribe, e-mail: For additional commands, e-mail: