Details
Description
When using a custom ViewPreparer the Attribute objects of the AttributeContext are apparently not deep-copied for the execute() function call.
So when the code is executed the first time and an attribute of the current tiles definition is set (changed from its original value) it will have the same changed value the next time the definition/preparer is called. Intended behaviour should be that the execute() function recieves a copy of the AttributeContext and copies of the included Attributes so that the original value is not touched when the preparer prepares the definition for the JSP file.
Simple test case:
tiles-def.xml:
<tiles-definitions>
<definition name="test.definition" template="/jsp/test.jsp" preparer="TestPreparer">
<put-attribute name="testAttr" value="1" />
</definition>
</tiles-definitions>
TestPreparer.java:
public class TestPreparer implements ViewPreparer {
public void execute(TilesRequestContext requestContext, AttributeContext attrContext)
}
test.jsp:
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
value of testAttr:
<tiles:insertAttribute name="testAttr" />
If you keep hitting the refresh button for the test definition in the browser, the value of testAttr increases each time, although it should be 2 always.