You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "PILGRIM, Peter, FM" <Pe...@rbos.com> on 2003/02/05 12:19:21 UTC

RE: DO NOT REPLY [Bug 16749] - Struts EL tag handlers cannot be reused by containers

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> On Tue, 4 Feb 2003 bugzilla@apache.org wrote:
> 
> >
> > Struts EL tag handlers cannot be reused by containers
> >
> 
> It sounds like these tags definitely have a problem.  There's 
> been some
> recent discussion on TOMCAT-USER about designing tags that 
> work reusably
> as well.
> 
> The bottom line:
> 
> * The container can reuse instances of tag handlers
>   when it sees that exactly the same set of attributes
>   is used (not necessarily the same values).
> 
> * This kind of reuse can happen whether or not the
>   container implements "tag pooling".
> 
> * When a tag handler instance is reused, the JSP page
>   compiler can decide if it has already set a particular
>   property on that instance, and omit the second set call.
>   For example, in:
>     <foo:bar a="1" b="2/>
>     <foo:bar a="1" b="3"/>
>   The second setA() call can be omitted, since the container
>   knows that it already called setA("1") the first time.
> 

Yep!

String a;
public void setA( String a ) {this.a = a;}
public String getA() { return a;}

> * If a tag instance is going to be reused, the doEndTag()
>   call on the first use is going to be followed by the
>   doStartTag() call of the second use.  Any per-use cleanup
>   activity needs to happen at the end of doEndTag().
> 
> * The net effect of all this is an important restriction -- it's
>   not legal for a tag handler to modify the values stored by
>   the setter calls from the page, *anywhere* in the path from
>   doStartTag() through doEndTag().

Are the many tags that are badly behaved. This make modification
on the value `a' in doStartTag() or doEndTag()

If the tag is doing this

	a += "foo ("+b+") bar";

then it cannot work as reusable tag.

To my knowledge, many tags are doing this. I have never written
tags that modify the input attributes. If I had I would use
automatic variables in local scope. 

> * The container will call release() after it has used the
>   instance for the last time.

--
Peter Pilgrim,
Struts/J2EE Consultant, RBoS FM, Risk IT
Tel: +44 (0)207-375-4923




***********************************************************************
      Visit our Internet site at http://www.rbsmarkets.com

This e-mail is intended only for the addressee named above.
As this e-mail may contain confidential or privileged information,
if you are not the named addressee, you are not authorised to
retain, read, copy or disseminate this message or any part of it.
The Royal Bank of Scotland plc is registered in Scotland No 90312
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB 
Regulated by the Financial Services Authority
***********************************************************************

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