Monday 29 October 2018

Prevent TO Load All Region's task flow on Page load

Prevent ADF Region Load 

Hi Guys,I faced performance Issue in my application and needs to prevent to load heavy query at initial stage.
When you run a page, by default, all Called regions will be loaded at once during the initial display of the parent page.if a page contains N regions, N task flows are executed during the page load. This is acceptable if all regions are exposed to the user during the initial display of the page itself. What if some regions are displayed in a pop up or inside a tabbed pane?
You may definitely want to defer the execution of these regions until an end user opts to view them. ADF task flow has declarative support for such scenarios. The task flow binding provides an activation flag to control the activation of the underlying task flow.

To set the appropriate activation property for a task flow, open the page definition file in the overview editor--> Select the desired taskFlow entry in the Executables--> select the appropriate value for the activation property in the Property Inspector window.
You can choose one from the following list:

immediate: This option activates the region immediately on the initial display of parent page. This is the default value for the activation flag....

we can follow below Implementation steps-

S1- Create an ADF Fusion web Application
S2- Create Business components for Emp table
S3- Create a view criteria where deptno=:bind_variable
S4- Create viewImpl Class and copy paste below code then expose this as client interface.

public void searchEmployee(Number deptNo)
{
          // Code to seacrh the deptnos

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

S5- Create BTF.
S6 - Create Fragment on BTF and drop the above method on the BTF.
S7- 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.
S8- Create  main.jspx page & drop the above taskflow as region on this page.

S9- Surround the region with the dialog & surround the dialog with the popup(id is Popup1)
       Drop the commandButton on the above page & insert showPopupBehavior inside                                 commandButton.

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

S10- 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

S11- Goto the bindings of the above main page--> select the taskflow binding -->set its activation               property to 'conditional'--> active property to Boolean value #{bean.popupVisible}.By default             its value should be false.

S12- setPropertyListener inside the popup:
      <af:setPropertyListener from="true" to="#{Somebean.popupVisible}" type="popupFetch"/>

S13- 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.


So This is how we can prevent the regions to load by default while loading the main page.

Cheers Guys :)


No comments:

Eclipse With Python

Hi Guys, Today i'll share how to start python project in eclipse IDE. to start Py development in eclipse we need to add Py Dev plugi...