How to set conditional activation to taskflows?

This article describes implementing conditional activation to taskflows.

Use Case Description

Suppose we have a taskflow dropped as region on a page & this region is enclosed in a popup .By default when the page is loaded the respective region also gets loaded.Hence a region model needs to provide a viewId whenever one is requested. 

A consequence of this is the TaskFlowRegionModel always has to initialize its task flow and execute the task flow's default activity in order to determine a viewId, even if the region is not visible on the page.This can lead to unnecessary performance overhead of executing task flow to generate viewIds for regions that are never visible.

In order to increase the performance,we need to set the taskflow bindings activation property to 'conditional'.Below described is a simple usecase that shows how exactly we can set the conditional activations to taskflow bindings.

Steps:

1.Create an ADF Fusion web Application

2.Create Business components for Emp table

3.Create a view criteria where deptno=:some_bind_variable

viewcrt.JPG
4.Generate EmpViewImpl.java file & write the below code.Then expose this to client interface.

    public void filterEmpRecords(Number deptNo)
{
    
       // Code to filter the deptnos

        ensureVariableManager().setVariableValue("some_bind_variable",  deptNo);
        this.applyViewCriteria(this.getViewCriteria("EmpViewCriteria"));
        this.executeQuery();
     
 }

5.Create an ADF Taskflow with page fragements & drop the above method on the taskflow

6.Also drop the view activity(showEmp.jsff) .Define control flow case from the above method activity to the view activity.Set the method activity as default activity

taskflow1.jpeg.JPG

7.Create  main.jspx page & drop the above taskflow as region on this page

region_main.jpeg.JPG


8.Surround the region with the dialog & surround the dialog with the popup(id is Popup1)

9.Drop the commandButton on the above page & insert af:showPopupBehavior inside the commandButton:

<af:commandButton text="show popup" id="cb1">
<af:showPopupBehavior popupId="::Popup1"/>
</af:commandButton>

10.Now if we execute this main page ,we will notice that the method action gets called even before the popup is launched.We can avoid this this by setting the activation property of the taskflow to conditional

11.Goto the bindings of the above main page & select the taskflow binding ,set its activation property to 'conditional' & active property to Boolean value #{Somebean.popupVisible}.
By default its value should be false.

mainbindings.JPG


12.We need to set the above Boolean value to true only when the popup is launched.This can be achieved by inserting setPropertyListener inside the popup:

<af:setPropertyListener from="true" to="#{Somebean.popupVisible}" type="popupFetch"/>

13.Now if we run the page,we will notice that the method action is not called & only when we click on 'show popup' button the method action gets called.

Comments:

thanks

Posted by guest on February 23, 2012 at 02:35 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Tips and Tricks from Oracle's JDeveloper & ADF QA

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today