tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trond Hersløv <trond.hers...@GOTOGATE.no>
Subject Custom tags and scope
Date Mon, 19 Sep 2005 11:56:46 GMT
Hi,
I do not have a lot of experience in programming custom tags.
Now, having programmed a couple of tags, I think it is kind of strage that I cannot narrow
the scope of variables defined in the taghandler down to the body of the custom tag.
It would for me clearly gain the purpose of code usability if so was the case.
I hope I have missed something and that there may is a way to configure the tld file so that
the scope of variables is restricted to the body. Here is the code to clarify what i mean:

TAGHANDLER (shortened for readability):
Public void doTag() extends JpsExtension{
  PageContext pc = (PageContext)getJspContext();
  JspFragment body = getJspBody();
  pc.SetAttribute("testvar", "myvalue");
  body.invoke(null);
}

JSP (shortend for readability):
<html><head><title>test</title></head>
  <my:testtag>${testvar}</my:testtag>
<!-- now, this should be out of the scope, but it isnt: -->
  ${testvar}
</html>


I do not want to specify or declare the variable first in the jsp.
I also think that using an attribute to hold the name of the variable used is a bad idea.
I absolutely want to use EL.

Is there any hope, or do I have to live with it?

Would appreciate any tips and workarounds

Regards Trond


**********************************************************************
This email message has been swept by
MIMEsweeper for the presence of computer viruses.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message