You are here

Adding a runtime picker to a taskflow parameter in WebCenter

In a previous post I have explained how you can create a LOV for an input parameter in WebCenter.
You can go a step further by creating a popup to allow the user to select items or do more complex things. The picker for an input parameter is a simple taskflow so you can make it as complex as you want to meet all your requirements.

An example of such a picker is the Start Folder Path of the Document Explorer taskflow:

This popup is more user friendly than when you need to type in the start folder yourself.

The documentation on how to create such a picker can be found here.

I will use the same technique to build a more useful example. Instead of adding a picker for a custom taskflow, I will create a picker for an out of the box taskflow from WebCenter.

In this example I will create a picker for the features Off parameter of the document explorer. This parameter allows you to customize the document explorer by disabling certain features. The problem with this parameter is that you have to know the exact name of the feature which few people actually know.

That's why I have decided to create a picker so you can easily check a checkbox for the features you want to disable.

You can download the example here.

Creating the taskflow

The first thing you need to do is create a taskflow and provide two input parameters:

It is important to use the names outParam and inParamVal because WebCenter expects those names and types.

You also have to create a taskflow return activity:

When you execute the OK action, you also have to populate the outParam with the output value which can be found in the populateReturnValue of my FeaturesOffBean:

  1.     public void populateReturnValue(ActionEvent ae) {
  2.         /**
  3.          * Imploding the array of selected items
  4.          * because the input parameter of the explorer taskflow
  5.          * is a String an not String[]
  6.          */
  7.         String featuresOff = "";
  8.         StringBuffer buffer = new StringBuffer(featuresOff);
  9.         for(String item : featuresOffList){
  10.             buffer.append(item + " ");
  11.         }
  13.         /**
  14.          * Putting the value on the output parameter so it can be read by the composer.
  15.          */
  16.         Map map = (Map)RequestContext.getCurrentInstance().getPageFlowScope().get("outParam");
  17.         if (map != null)
  18.           map.put("outParamVal", buffer.toString());
  19.       }

As you can see we have to add a value to the map with key outParamVal. It is also important to stick with the names!
The cancel button just looks for a popup and cancels it:

  1.       public void closePickerPopup(ActionEvent ae) {
  2.         UIComponent component = ae.getComponent();
  3.           while (!(component instanceof RichPopup))
  4.             component = component.getParent();
  5.             if (component != null)
  6.               ((RichPopup)component).cancel();
  7.       }

Securing the taskflow

Because WebCenter uses ADF Security by default, you need to configure security for the taskflow. By default, new resources don't have any security which means that nobody can view them so you have to grant access in the resource grants section of the jazn-data file:

The rest of the code is just some logic that you can build.

In this example it populates a list of checkboxes and convert the values into a normal string so we can pass it on to the output value.

Registering the taskflow as a picker

The next big thing is registering the taskflow as a picker. This is done in the pe_ext.xml file in the META-INF folder of the Application Sources:

  1. <pe-extension xmlns="">
  2.  <lov-config>
  3.   <task-flow-definition taskflow-id="/oracle/webcenter/doclib/view/jsf/taskflows/explore/explorer.xml#doclib-explorer">
  4.     <input-parameter-definition>
  5.       <name>featuresOff</name>
  6.       <value>null</value>
  7.       <enumeration picker="/WEB-INF/featuresOffPicker.xml#featuresOffPicker"/>
  8.     </input-parameter-definition>
  9.   </task-flow-definition>
  10. </lov-config>
  11. </pe-extension>

Notice that the task flow definition points to an oracle out of the box taskflow instead of a custom one.

The picker itself is defined by the picker attribute on the enumeration tag.

That's basically it. It's not that difficult to do. The most important part is that you keep the names of the input parameter of the taskflow. Otherwise it will not work.

This is how it looks when you select the picker:

When I press OK the featuresOff field will be populated with the value:

And the explorer will disable those features:

That's about it.

You can make those pickers as complex as you want. Remember that they are normal taskflows so you can create a flow between views, create advanced LOV's and so on.

ADF Tags: 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer