The ATG platform provides a way for you to mark certain components as having session scope, as opposed to global scope. If a component is marked as having session scope, then every user gets a separate copy of the object.

You can view and change the scope of a component in the Basics tab of the Component Editor. The Scope field displays the current scope of the component. You can change a component’s scope by clicking the Scope field and setting the component’s scope to global, session, or request.

You can also specify the scope of a component in the properties file, using the special $scope property:

$class=Person
$scope=session
name=Bill
age=28

Change the scope of the /test/services/NewPerson component to session scope. Now if you repeat the exercise from the previous section, you’ll notice that each browser is accessing a separate copy of the NewPerson component.

Nucleus supports three scopes: session, global, and request, all specified through the $scope property. If a component specifies no scope, the scope defaults to global.

 
loading table of contents...