[
https://issues.apache.org/struts/browse/TILES-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45173#action_45173
]
Zach Bailey commented on TILES-338:
-----------------------------------
Please note that while this Tag overrides the release() method which DOES null
the value instance member, this method is not guaranteed to be called between
every single invocation of the tag (e.g. when the tag is used multiple times on
one page). For more information please see the tag lifecycle as documented here:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/Tag.html
especially:
Methods
There are two main actions: doStartTag and doEndTag. Once all appropriate
properties have been initialized, the doStartTag and doEndTag methods can be
invoked on the tag handler. Between these invocations, the tag handler is
assumed to hold a state that must be preserved. After the doEndTag invocation,
the tag handler is available for further invocations (and it is expected to
have retained its properties).
Lifecycle
Lifecycle details are described by the transition diagram below, with the
following comments:
[1] This transition is intended to be for releasing long-term data. no
guarantees are assumed on whether any properties have been retained or not.
[2] This transition happens if and only if the tag ends normally without
raising an exception
[3] Some setters may be called again before a tag handler is reused. For
instance, setParent() is called if it's reused within the same page but at a
different level, setPageContext() is called if it's used in another page, and
attribute setters are called if the values differ or are expressed as
request-time attribute values.
Check the TryCatchFinally interface for additional details related to exception
handling and resource management.
Once all invocations on the tag handler are completed, the release method is
invoked on it. Once a release method is invoked all properties, including
parent and pageContext, are assumed to have been reset to an unspecified value.
The page compiler guarantees that release() will be invoked on the Tag handler
before the handler is released to the GC.
> AddAttributeTag only uses the first "value" ever set
> ----------------------------------------------------
>
> Key: TILES-338
> URL: https://issues.apache.org/struts/browse/TILES-338
> Project: Tiles
> Issue Type: Bug
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.1.0
> Reporter: Zach Bailey
>
> In AddAttributeTag#doAfterBody:
> /**
> * Save the body content of this tag (if any).
> *
> * @return It returns <code>SKIP_BODY</code>.
> */
> public int doAfterBody() {
> if (value == null && bodyContent != null) { //bug here
> value = bodyContent.getString();
> type = "string";
> }
> return (SKIP_BODY);
> }
> The value of this tag is only being updated if there is not already a value
> set. So, when this tag is used twice in succession on a page, it will always
> only use the first "value" ever set!!!
> I looked back at the older Tiles 2.0.6 version we were using and the code is
> correct in that version - there is no "value == null" check. So, it looks as
> though someone added this little check at some point in the 2.1 release, but
> it seems to severely break things (at least for me!)
> I see two ways of fixing this -
> 1.) Simply remove the value == null check, or if this check is in place for a
> reason,
> 2.) Reset value to null after each execution of the tag in doEndTag, or
> doFinally() from the TryCatchFinally interface:
> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/TryCatchFinally.html
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.