Thursday 20 March 2014

Oracle ADF : How and where to define managed bean ?


How and where to define managed bean ?

Managed beans are Java classes that you register with the application using various configuration files. When the JSF application starts up, it parses these configuration files and the beans are made available and can be referenced in an EL expression, allowing access to the beans' properties and methods.

Memory scopes of manage beans :

In ADF we have following scopes

Request scope – The object is available from the time an HTTP request is made until a response is sent back to the client. Use request scope when the managed bean does not need to persist longer than the current request.

Backing bean scope – A backing bean is a convention to describe a managed bean that stores accessors for UI components and event handling code on a JSF page. This scope is needed because there may be more than one page fragment or declarative component on a page, and to avoid collisions between values, any values must be kept in separate scope instances. Use backingBeanScope scope for any managed bean created for a page fragment or declarative component.

View scope - The object is available until the ID for the current view changes. Use view scope to hold values for a given page.

Page flow scope – The object will be available as long as the user continues navigating from one page to another in the task flow.

Session scope - The object is available for the duration of the session.

Application scope - The object is available for the duration of the application.

A more detail reference can be found at http://docs.oracle.com/cd/E14571_01/web.1111/b31973/af_lifecycle.htm#CHDGGGBI
4.6 Object Scope Lifecycles

Where to define manage bean :

In adf we can define our managed beans in following files –

1.faces-config.xml – This was used in JSF application for defining navigation model and manage bean entries. It does not have page flow scope and view scope as these are added by ADF.

2.adfc-config.xml – All scopes can be defined here available in ADF. A manage bean defined here can be used anywhere in application.   

3.Task flow definition file – Only scopes which are smaller or equal to page flow scope (i.e pageflow, view, backing bean) can be defined here or will be meaningful to be define. This manage bean object can be used for any page used within the task flow.

A more detail reference can be found at http://docs.oracle.com/cd/E15523_01/web.1111/b31974/web_getstarted.htm
20.4 Using a Managed Bean in a Fusion Web Application

No comments:

Post a Comment