ViewPreparer does not deep copy Attributes of AttributeContext
--------------------------------------------------------------

                 Key: TILES-429
                 URL: https://issues.apache.org/struts/browse/TILES-429
             Project: Tiles
          Issue Type: Bug
          Components: tiles-core
    Affects Versions: 2.1.2
         Environment: Tomcat 6.0, Tiles 2.1.2
            Reporter: Nino Ulsamer


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) {
                int testValue = 
Integer.parseInt(attrContext.getAttribute("testAttr").getValue().toString());
                // testValue (value of testAttr) should be 1, since that is 
what we defined in tiles-defs.xml

                // now we change testAttr (increment by 1) and save it - so it 
should always be 2
                testValue++;
                attrContext.getAttribute("testAttr").setValue(""+testValue);
        }
}


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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to