How to set conditional activation to taskflows?
- by shantala.sankeshwar(at)oracle.com
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 ApplicationView image
2.Create Business components for Emp tableView image3.Create a view criteria where deptno=:some_bind_variableView image4.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 taskflow6.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 activityView image7.Create main.jspx page & drop the above taskflow as region on this pageView image8.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 conditional11.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.View image12.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.