From c620aa40ef16d8feb23d26a765913d58593e9383 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Mon, 25 Dec 2023 20:11:50 +0100 Subject: [PATCH 1/2] Revert "Update scope.adoc (#509)" This reverts commit 9b3884de44bfbca947d71c4c296112e64ec2dea6. --- src/en/ref/Controllers/scope.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/en/ref/Controllers/scope.adoc b/src/en/ref/Controllers/scope.adoc index 0641332f111..216f2f2f2b5 100644 --- a/src/en/ref/Controllers/scope.adoc +++ b/src/en/ref/Controllers/scope.adoc @@ -26,11 +26,11 @@ class BookController { === Description -Unless specified by the `grails.controllers.defaultScope` property in `application.yml`, controllers by default are "singleton" scoped which means that only one instance of the controller exists. +Unless specified by the `grails.controllers.defaultScope` property in `application.yml`, controllers by default are "prototype" scoped which means that a new controller will be created for each request. This behaviour can be set for an individual controller by specifying a `scope` attribute with one of the following values: -* `singleton` (default) - Only one instance of the controller ever exists (recommended for actions as methods) -* `prototype` - A new controller will be created for each request (recommended for actions as Closure properties) +* `prototype` (default) - A new controller will be created for each request (recommended for actions as Closure properties) * `session` - One controller is created for the scope of a user session +* `singleton` - Only one instance of the controller ever exists (recommended for actions as methods) See link:{guidePath}/theWebLayer.html#controllersAndScopes[Controllers and Scopes] in the user guide for more information. From 2281d5d03d2e637055a295d4d2da345b36d64cf6 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Mon, 25 Dec 2023 20:31:36 +0100 Subject: [PATCH 2/2] docs: Add note about controller scope --- src/en/ref/Controllers/scope.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/en/ref/Controllers/scope.adoc b/src/en/ref/Controllers/scope.adoc index 216f2f2f2b5..748cf424d9b 100644 --- a/src/en/ref/Controllers/scope.adoc +++ b/src/en/ref/Controllers/scope.adoc @@ -26,11 +26,13 @@ class BookController { === Description -Unless specified by the `grails.controllers.defaultScope` property in `application.yml`, controllers by default are "prototype" scoped which means that a new controller will be created for each request. -This behaviour can be set for an individual controller by specifying a `scope` attribute with one of the following values: +Unless specified by the `grails.controllers.defaultScope` property in `application.yml`, controllers are by default "prototype"-scoped which means that a new controller will be created for each request. +The scope can be set for an individual controller by specifying a static `scope` attribute with one of the following values: * `prototype` (default) - A new controller will be created for each request (recommended for actions as Closure properties) * `session` - One controller is created for the scope of a user session * `singleton` - Only one instance of the controller ever exists (recommended for actions as methods) +NOTE: Newly created applications have the `grails.controllers.defaultScope` config property set to a value of "singleton" in `application.yml`. + See link:{guidePath}/theWebLayer.html#controllersAndScopes[Controllers and Scopes] in the user guide for more information.