Sunday, October 23, 2011

Oracle ADF setting Task flow to use same page definition file of caller page

Hi,

In this post i will show a little technique which i learn from Steve Davelaar session 'Building Highly Reusable task flows' at Oracle open world.

If you want to pass parameter from one page to bounded task flow generally you would use a pageFlowScope variable and then use that variable as input parameter to the task flow.

In this trick or technique we will setup a task flow so it will use the same Page definition file of calling page. With this we can use the all bindings on the caller page inside our bounded task flow.

Note: This is not recommended solution for beginners (There is a chance you could mess up the ADF project). This is just another way to do things Steve said that he had open an enhancement request with ADF development team.

Lets get into the example Download the complete example 

Application Flow:

Page 1 is displaying a list of departments along a button Show Employees with each record. By Pressing Show Employees a bounded task flow will be called which takes an input parameter of current department Id and pass to employees BTF which executes the query of the current department id





Preparing Model project


There is nothing special to setup model project except the Employees View object query using a bind variable of department id to filter records.



There is NO relation between departments and employees view objects in Application Module data model because we don't need dependency between collections



Preparing Employees Task flow

Employees task flow is as shown in the slide


Employees task flow will take one single input parameter



Drag and drop ExecuteWithParams operation from data control to task flow and set the input parameter as similar to the value of input parameter

Call task flow from departments page

the unbounded task flow contains a departments page the task flow is as shown in the slide



Prepare Employee Task flow to share page definition of Department page

1. Right click the Task flow and choose Create Page definition.



2. Now you can see the page definition file has been created



3. Double click the DataBindings.cpx file click on Source. Under pageMap entries you can see the list of pages. every page id every one has unique reference to its page def file


4.  Copy the usageId of deptList page to showEmps task flow also change under Page Id and replace the path of page definition file as shown in the slide Save the file later on


5. Delete the old page definition file of showEmps we don't this file anymore. make sure when you delete it says '0 usages found' as shown in the slide



6. Now go to unbounded task flow which contains the departments page and bounded task flow
click on the showEmps task flow go to properties and use EL expression to set the value of input parameter as binding of departmentId as shown in the slide (we can only see this because now task flow is sharing the same page definition file as department page)


Note: I have attribute binding called departmentId in department Page






Now we are all set. Run the example and see

Happy Jdeveloping,
Zeeshan Baig



3 comments: