At any given time, a session-scoped or request-scoped component might have multiple instances. For example, a session-scoped component instance might exist for each user logged on to the site.

When a component instance is created, the ATG platform does not create objects for its properties. In order to minimize memory use, new component properties are set as pointers to existing instances of those objects. Consequently, be careful how you set properties of a session-scoped or request-scoped component; changing the value of a property is liable to affect other component instances, depending on the property data type:

For example, given an array property myArrayString[] set to {"a", "b", "c"}, you should change its last element by creating an array with the desired change and setting the property to it:

setMyArray(new String[] {"a", "b", "z"}

Conversely, the following code incorrectly modifies the array in place, and is liable to affect other component instances:

String[] arr = getMyArray()
arr[2] = "z";

loading table of contents...