Dynamic Taskflow with conditional activation

Use Case – How dynamic task flow activated conditionally.

Implementation – We have two ADF application .One is consumer application which have two task flow

Now we have consumer application which show no task flow on load.Task flow will be shown on click of button .If you click task flow 1 then tf1 will be called and vice versa.Till the button is clicked neither tf1, nor tf2 wud be executed.

Create Producer application-

Create an new ADF application. Create two new task flow as Sample1TF and Sample2TF as below –


Now in each task flow drag drop and view activity and Sample1PF in above screenshot.Same steps need to be done for Sample2TF. Drag drop again an view activity as Sample2PF.jsff

Sample2PF.jsff will be like this


Now project structure would be like


Now the deploy this project as ADF library jar.


Create Consumer Application –

Now we will be creating an consumer application. We will create an .jsff page with two button. Clicking on any button will called specific task flow.


We will drag drop region in the page and task id will be called .Binding of the page is as follow-


activation: Though you can specify values like conditional/deferred/active for this flag, in this post I discuss conditional activation. Setting activation=conditional, activates the ADF region if the EL expression set as a value for the task flow binding ‘active’ property(discussed below) returns true

active and task flow id will passed through an managed bean.Code of following bean as below

public class ProducerPocManagedBean {

private String taskFlowId = “/WEB-INF/com/sss/poc/Sample1TF.xml#Sample1TF”;

private Boolean activateRegion = Boolean.FALSE;

private RichRegion pocDynamicRegion;

public ProducerPocManagedBean() {

}

public TaskFlowId getDynamicTaskFlowId() {

return TaskFlowId.parse(taskFlowId);

}

public void setTaskFlowId(String taskFlowId) {

this.taskFlowId = taskFlowId;

}

public String getTaskFlowId() {

return taskFlowId;

}

public void setActivateRegion(Boolean activateRegion) {

this.activateRegion = activateRegion;

}

public Boolean getActivateRegion() {

return activateRegion;

}

public void loadTF1AL(ActionEvent actionEvent) {

// Add event code here…

activateRegion = Boolean.TRUE;

taskFlowId = “/WEB-INF/com/sss/poc/Sample1TF.xml#Sample1TF”;

AdfFacesContext.getCurrentInstance().addPartialTarget(pocDynamicRegion);

}

public void loadTF2AL(ActionEvent actionEvent) {

// Add event code here…

activateRegion = Boolean.TRUE;

taskFlowId = “/WEB-INF/com/sss/poc/Sample2TF.xml#Sample2TF”;

AdfFacesContext.getCurrentInstance().addPartialTarget(pocDynamicRegion);

}

public void setPocDynamicRegion(RichRegion pocDynamicRegion) {

this.pocDynamicRegion = pocDynamicRegion;

}

public RichRegion getPocDynamicRegion() {

return pocDynamicRegion;

}

}

Then drag drop this jsff into one .jspx page. That’s all .Now you can run the application. Following will be screenshot of the page.


Click on button Load TF1


Click on button Load TF2


check attached for source code

DynamicTaskFlowPOC

Happy Learning with Vinay Kumar in techartifact

Dynamic Creation of cascading Lov in oracle ADF or model driven Lov in Oracle ADF.

Requirement – I am working on tricky requirement where i have two child component and one child LOV.How to do that?

Solution- Well if you have working knowledge of cascading LOV in then we pass bind parameter of parent LOV attribute in child LOV View Accessor(VA) . But in this scenario , we have two master LOV. then we will be doing by passing through managed bean, using Application module session .

What i have done.I have used HR schema .

I have 3 view object. one as country table of HR schema.One View object for location table.One view which have all transient attribute and consider to be main view object.

As i found this approach in Jobinesh’s blog- i write a custom method in applicationModuleImpl.java as below –

    public void setLocationIDSessionData(String locId){
          System.out.println("hello 232323&&&"+locId);
        this.getSession().getUserData().put("LocationId", locId);
        
      }

I have getUserData method of applicationModule interface which returns a java.util.Hashtable which may be used to store user specific context that is related to this application session.

Read all other method related to this
http://docs.oracle.com/cd/E12839_01/apirefs.1111/e10653/oracle/jbo/ApplicationModuleHandle.html

Ok, coming back to this requirement – I used a managed bean in backing bean scope where i executed the binding of applicationModuleImpl custom method as below –

    public void executec(String valueChangeEvent) {
    BindingContext bctx = BindingContext.getCurrent();
           BindingContainer bindings = bctx.getCurrentBindingsEntry();
           OperationBinding op =
               (OperationBinding)bindings.getOperationBinding("setLocationIDSessionData");
           op.getParamsMap().put("locId",valueChangeEvent);
           op.execute();
    }

Here we are passing the value of both LOV to locationId to custom applicationModuleImpl method.In both parent LOV , i create valuechangeEvent method , which get the current selected countryId and pass to custom applicationModuleImpl method. that is below –

    public void VC(ValueChangeEvent valueChangeEvent) {
      System.out.println("hello &&&"+valueChangeEvent.getNewValue());
      
       
        executec(valueChangeEvent.getNewValue().toString());
    }

    public void vc2(ValueChangeEvent valueChangeEvent) {
        System.out.println("hello &&&34343"+valueChangeEvent.getNewValue());
        executec(valueChangeEvent.getNewValue().toString());
    }

Now we have final task, we have to set the value of child lov bind parameter in child View Accessor as adf.userSession.userData.LocationId

That’s it.now we will run the jspx , which have all 3 lov.2 parent and one child LOV.
for displaying LOV , we need to click on create button.after click you can see all 3 LOVs.

After selecting county as CH from countryLov1 , we will see different values in location ID.

Now we will select country as IN from countryLov2 , we will see different values in location ID.

You can download the sample application here.

ModelDrivernCascadingLOVs

Happy coding with Vinay kumar in techartifact….