Using a task flow initializer to initialize a task flow

To initialize, there are two ways of doing that.either using method call activity and using initializer of task flow.

An initializer is custom code that is invoked when an ADF bounded task flow is entered. You specify both the initializer and finalizer as an EL expression for a method on a managed bean, for example, #{pageFlowScope.modelBean.releaseResources}.

When to use what.

Use a method call activity – -No reentry via back button expected: Designate a method call activity as the default activity (first to execute) in the ADF bounded task flow. The method call activity calls a custom method containing the intializer code.

Use a Initializer of TaskFlow- Back button reentry possible: Specify an intializer method using an option on the ADF bounded task flow metadata. Use this technique if you expect that a user may reenter the task flow using a browser back button. In such a case, the designated default activity for the bounded task flow may never be called, but a method designated using the Initializer method will.

Now we will see how we can implement that-

Write a method which we need to call before taskflow in applicationModuleImpl.java .Expose to client interface of application module so that it will come in data control

 public void prepare() {
// get the Employees view object instance
EmployeesImpl employees = this.getEmployees();
// remove all rows from rowset
employees.executeEmptyRowSet();
// create a new employee row
Row employee = employees.createRow();
// add the new employee to the rowset
employees.insertRow(employee);
}

– Right-click on the ViewController project in the Application Navigator and select New…. Select ADF Task Flow from the Web Tier | JSF/Facelets category.

– In the Create Task Flow dialog, enter taskflowInitializer.xml for the task flow File Name and ensure that you have selected the Create as Bounded Task Flow
checkbox. Also make sure that the Create with Page Fragments checkbox is not selected. Then click OK.

– The taskflowInitializer task flow should open automatically in Diagram mode. If not, double-click on it in the Application Navigator to open it. Click anywhere in
the task flow, then in the Property Inspector change the URL Invoke property to urlinvoke-allowed.

– Go to the task flow Overview | Managed Beans section and add a managed bean called InitializerBean. Enter com.techartifact.jdeveloper.hr.main.view.beans.Initializer for the managed bean Class and select pageFlow for the bean Scope

– While at the Managed Beans section, select Generate Class from the Property Menu next to the Managed Bean Class in the Property Inspector.

– Locate the Initializer.java bean in the Application Navigator and open it in the Java editor. Add the following initialize method to it

public void initialize() {
// get the application module
HrComponentsAppModule hrComponentsAppModule =
(HrComponentsAppModule)ADFUtils
.getApplicationModuleForDataControl(
"HrComponentsAppModuleDataControl");
if (hrComponentsAppModule != null) {
// call the initializer method
hrComponentsAppModule.prepare();
}
}

– Return to the task flow, diagram and add a task flow initializer by clicking on the Property Menu next to the Initializer property in the Property Inspector and
selecting Method Expression Builder.

– In the Expression Builder dialog that opens, locate and select the initialize method of the InitilizerBean under the ADF Managed Beans node. The click OK to dismiss
the dialog. The initializer expression #{pageFlowScope.InitializerBean.initialize} should be reflected in the Initializer property of the task flow in the
Property Inspector.

Thats it.

finalizer is also an important part.finalizer is custom code that is invoked when an ADF bounded task flow is exited via a task flow return activity or because an exception occurred. The finalizer is a method on a managed bean. Common finalizer tasks include releasing all resources acquired by the ADF bounded task flow and perform cleanup before exiting the task flow.

Happy coding with Techartifact with Vinay ….

Q: What are different Task Flow Component?

Method call-Provide a way to execute code within the flow.
Router – Provided way to branch the flow based on condition or by el.
Save Point Restore: Allows developer to take a snapshot of and ,then resotre,application state at specific point in flow.
Task Flow Call-Allow task flow to be called from this task flow.
URL View-Way to reach out the flow and potentiallu out og web application to some arbitrary URL such as http://www.techartifact.com
View:Allow display of page and page fragment.
Control Flow Case: Define flow between two activies.Similar to navigation case in ADF 10g or default jsf navigation engine.
WildCard Control Flow Rule: Provides way to define an origin for one or more global control flow cases that are shared and available from multiple activities on the diagram.

Oracle ADF-Parent Action Activity in ADF Task Flow – Techartifact

Recently I have faced a problem, when was trying to navigate to ADF Task Flow Call activity. The problem was, that I was initiating navigation from inside the region and navigation flow was defined not in bounded region ADF Task Flow, but inside parent bounded page ADF Task Flow. This means, navigation outcome from parent ADF Task Flow was simply invisible for button I have created inside region. But as usual in most of the cases, ADF provides very elegant solution to solve problem of external navigation from inside the region

This depicts in this videos please watch.-

Source – http://andrejusb.blogspot.com/2009/05/parent-action-activity-in-adf-task-flow.html

Pin it