Donnerstag, 17. März 2011

Providing Input Parameters for Taskflows in UI Shell

When trying out to build your own UI Shell based application you possibly have used the pre-implemented source code for your launcherBean that can be found under

This code works well, but if you want to pass parameters into a taskflow the Launcher class does not provide any interface. The solution is simple but powerful. Of course, it is already implemented in our customized ADF Juggernaut Shell Test Application. Please notice: To run our sample application you might have to add the ADF Juggernaut Shell Template to your CLASSPATH.

After decompiling the dynamic tabs shell template we took a look into UI Shell's TabContext class. There you can see two appearances of a method called addTab:

public void addTab(String localizedName, String taskflowId);
public void addTab(String localizedName, String taskflowId, Map<String, Object> parameters);

As you can see in the signature of the second addTab-Method, UI Shell provides the possibility to pass a Map<String, Object> that holds parameters for our task flow. Keeping that knowledge in mind we are able to modify the Launcher class provided by OTN in two steps:

1. Overload method _launchActivity
In order to overload the pre-implemented _launchActivity method edit and insert the following code snippet:
private void _launchActivity(String title, String taskflowId, boolean newTab,
                               Map<String, Object> parametersMap) {
    try {
      if (newTab) {
        TabContext.getCurrentInstance().addTab(title, taskflowId,
      } else {
        TabContext.getCurrentInstance().addOrSelectTab(title, taskflowId,
    } catch (TabContext.TabOverflowException toe) {

2. Simplify old _launchActivity method
For consistency reasons we should modify the "original" _launchActivity method in the following way:
private void _launchActivity(String title, String taskflowId,
                               boolean newTab) {
    this._launchActivity(title, taskflowId, newTab, null);

Now we are able to pass parameters into taskflows! 

An example of passing a parameter into a taskflow is shown in our ADF Juggernaut Shell Test Application.  In the sample application we define an action listener method for our "Parameter Task Flow" button .

public void launchWithParameterTaskFlow(ActionEvent actionEvent) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("inParameter", "I'm the Juggernaut!");

                    false, map);

When the button is clicked we generate a HashMap that contains the parameter inParameter with its value "I'm the Juggernaut!". This map is used to pass the containing parameter into the taskflow via _launchActivity method.

The taskflow itself contains a single view activity with a corresponding page fragment. To use the inParameter we passed, we have to define an input paramter in our taskflow. To do this open the taskflow and click somewhere, but not onto the view activity. The property inspector should show the task flow definition attributes now. Under section Parameters we can see the subsection Input Parameter Definitions. Click the green plus to add a new parameter. Name the parameter inParameter and define that its class is java.lang.String. The fields "value" and "required" should be empty. As you can see, the name of the task flow input parameter must match the key we passed in our parameters map via _launchActivity method.

As intended, we are able to use the input parameter within the taskflow by using the EL expression #{pageFlowScope.inParameter}

Please notice: To run our sample application you have to add the ADF Juggernaut Shell Template to your CLASSPATH.

Keine Kommentare :

Kommentar veröffentlichen