Mac Ferguson wrote:

> ...
> Theoretically tags should be stateless, so these default values should be
> being assigned in the doStartTag() method not in instance variable
> declarations. Another part of the spec which was pointed out to me indicates
> that successive calls to the same tag with the same attribute values may not
> trigger the setter methods, here's the quote from the spec:
>
> "From the spec,  JSP 10.1, "Once properly set, all properties are expected
> to be
> persistent, so that if the JSP container ascertains that a property has
> already
> been set on a given tag handler instance, it needs not set it again.""
>
> which once again implies that if any instance-specific initialization needs
> to be done in a tag, it should be done in doStartTag() or some submethod
> which will be called on every use of the tag instance.
>
> My first thought was that release() should be implemented to reset state,
> but the comments for the lifecycle diagram on page 165 of the spec indicate
> that release is "intended to be for relleasing long-term data" and there is
> no guarantee that properties are retained or not.

5.4.2 of the JSP 1.1 spec says explicitly that "Once all invocations on the tag
handler are completed, the release method is invoked on it. Once release method
is invoked all properties are assumed to have been reset to an unspecified
value."

Unless something has changed in 1.2 release() is what should be resetting the
state, including all the property values. That still leaves the issues from
Shawn's email regarding properties set for one use of the tag carrying over to
another use of the tag.

I'd suggest that the spec should either require reset to be called before a tag
is reused (at least with a different set of attributes), or should have some way
of explicitly setting an attribute to the unused state. I haven't looked into
1.2 to see if it has such a requirement, though.

  - Dennis

Reply via email to