From time to time, I see lots of people messed up with managed bean memory scopes as the application complexity increases. Those errors you would see are types of Null Pointer Exception or the bean/its attribute/method cannot be found. Most of the time the reason behind it is its managed bean memory scope is not set up properly.
JSF web application itself has 4 types of scopes: application, session, request and none; ADF technology has brought 3 additional types of scopes: page flow, view and backing bean. The most common ones being used across an ADF fusion application are request, page flow, view and backing bean. Though placing a managed bean into a bigger scope than it should be will still work for your application most of the time but will bring cost on the overhead, placing the bean the other around will definitely stop your application from working properly.
If you are working on the ADF fusion application, the developer's guide should the first resource to refer. The following table list 3 locations of registering your managed bean and their rules of thumb:
Additionally, the guide says:
As a general rule for Fusion web applications, a bean that may be used in more than one page or task flow, or one that is used by pages within the main unbounded task flow (
The most common mistakenly setup of managed bean scopes in an ADF fusion application are:
JSF web application itself has 4 types of scopes: application, session, request and none; ADF technology has brought 3 additional types of scopes: page flow, view and backing bean. The most common ones being used across an ADF fusion application are request, page flow, view and backing bean. Though placing a managed bean into a bigger scope than it should be will still work for your application most of the time but will bring cost on the overhead, placing the bean the other around will definitely stop your application from working properly.
If you are working on the ADF fusion application, the developer's guide should the first resource to refer. The following table list 3 locations of registering your managed bean and their rules of thumb:
Managed Bean Placement | Effect |
---|---|
adfc-config.xml |
|
Task flow definition file |
|
faces-config.xml |
|
Additionally, the guide says:
As a general rule for Fusion web applications, a bean that may be used in more than one page or task flow, or one that is used by pages within the main unbounded task flow (
adfc-config
), should be registered in the adfc-config.xml
configuration file. A managed bean that will be used only by a specific task flow should be registered in that task flow's definition file. There should be no beans registered in the faces-config.xml
file.The most common mistakenly setup of managed bean scopes in an ADF fusion application are:
- A bean is used in more than one page or task flow and registered in one of the task flow definition files
- A bean for page fragment in a task flow is not put into the backing bean scope.
- Put a common accessible bean into faces-config.xml
- Put a bean in adfc-config.xml and choose the scope as "PageFlowScope"
- Put a bean in a bigger scope than it should.
Comments