Friday, 13 January 2017

Difference between Action & Action Listener in ADF?

Action:-
We Know Actions are designed for business logic and participate in navigation handling
To understand the above line we must understand the below context.
Using Action we can perform both static navigation & Dynamic Navigation
Static Navigation is achieved by  just providing the Control flow outcome between pages in the action attribute in property inspector for a UI component.

Dynamic navigation is nothing but executing some business logic before navigation.
for ex:- Binding a button to a method on backing bean which executes some code and based on that result it returns an outcome. The returned outcome will determine the navigation rule that is implemented.
If your code have multiple return values then multiple navigation's from current page will occur.
Note that the return values should be either String or null .



ActionListener:
Action listeners typically perform user interface logic and do not participate in the navigation handling.
Action listener is a class that wants to be notified when a command component fires an action event.
Mostly we will see Action Listener when we drag & drop some operation(like commit, delete) from DataControl on to a JSF page . These operations just execute some code behind the page.
Note:
Use Action when u want to execute some logic before navigating to another page.i.e., Dynamic Navigation
Use Action listener just to execute some logic and to stay on the page itself.
Scope of managed bean is a very important aspect while developing applications, so it is necessary to clearly understand memory scope of managed bean-


Application Scope-
The application scope lasts until the application stops. Values that you store in a managed bean with this scope are available to every session and every request that uses the application.
Avoid using this scope in a task flow because it persists beyond the life span of the task flow.
 
Session Scope-
The session scope begins when a user first accesses a page in the application and ends when the user's session times out due to inactivity, or when the application invalidates the session.
Use this scope only for information that is relevant to the whole session, such as user or context information. Avoid using it to pass values from one task flow to another. Instead, use parameters to pass values between task flows. Using parameters gives your task flow a clear contract with other task flows that call it or are called by it. Another reason to avoid use of session scope is because it may persist beyond the life span of the task flow.
 
 
Pageflow Scope-




Choose this scope if you want the managed bean to be accessible across the activities within a task flow. A managed bean that has a pageFlow scope shares state with pages from the task flow that access it. A managed bean that has a pageFlow scope exists for the life span of the task flow.If another task flow's page references the managed bean, the managed bean creates a separate instance of this object and adds it to the pageFlow scope of its task flow.
  

Request Scope-
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. It exists for the duration of a request and should not be used to maintain state.
Use this scope if it is possible that your task flow appears in two ADF regions on the same JSF page and you want to isolate each instance of ADF region.