Tuesday, 15 December 2015

Oracle ADF/Fusion Web Application Scopes

Def: Scope means how much time that object can be available. ie life time of an object
Usage: At run time, you pass data to pages by storing the needed data in an object scope where the page can access it. The object can be accessed from the scope using an EL expression.
Types: We have seven types of scopes. In which 3 are ADF scopes and remaining 4 are standered jsf/jspx scopes

Types of Scopes:
Four types of jsf/jspx scopes:
1. None scope: When you create objects that requires to define a scope. When you set the scope to none, meaning that it will not live in any particular scope, but will instead be instantiated each time it is referenced. You should set beans scope to none when it is referenced by another bean.
2. Request scope: It can be available once the request is raised and response is rendered back, Once the response rendered this scopes getting expired. It is the least scope, 
3.Session scope: The object can be available duration of the session,  whic is user instance specific. This scope can be used to maintain the user name in all pages,  which is read from database/LDAP server to avoid unnecessary queries.
4. Application scope: The object can be available duration of the application ie Whenever our application is running, this scope can be available. It can be used to maintain the static data irrespective of all users. This is the largest scope, Oracle is not recommended to use

Three types ADF scopes:
5. View scope: This scope can be available to particular jspx/jsff page. When the view id changes, this scope can expired.
6. PageFlow scope: In this the object can be available for the particular task flow only, Whenever task flow id changes this scope getting expired. If a task flow having hundred pages, this scope can be available in all hundred pages.
7. Backing bean scope: In most of the cases request scope and backing bean scopes are same. Only difference is that whenever we drag and drop task flow fragments as dynamic regions in that case we use backing bean scope. Because if drag and drop same task flow more than once, when we change the value in taskflow1 it will be reflected in taskflow2 also. So to avoid this type of problems we can use backing bean scope
Note: To be safe side, while drag and drop task flow as regions use backingbean scope.

Order of scopes(Min to max)
1. None Scope
2. requestScope/backingBeanScope
3. viewScope
4. pageFlowScope
5. sessionScope
6. applicationScope

2 comments: