25 May 2013

ADF Task Flow Display Name

ADF Task Flow definition has a set of description properties:

In this post I am going to show how we can make use of these properties on example of Display Name attribute. Let's consider a region with a running task flow within it. In common case the region is dynamic one, so we don't know in advance which task flow it is going to run. Moreover, the task flaw can invoke another inner task flow, and the inner task flow can invoke its inner task flow, etc. Our goal is to show in the region's title the name of the currently running task flow. Let's assume, that all our task flow definitions have initialized property Display Name with a corresponding name as it is shown on the screenshot above. We can use a managed bean method returning a display name of the currently running task flow:

public String getTaskFlowDisplayName() {
    MetadataService metadataService = MetadataService.getInstance();

    //Get the task flow binding defined in our pageDef file
    DCTaskFlowBinding taskFlowBinding = getTaskFlowBinding();

    //Get Id of the currently running task flow
    TaskFlowId taskFlowId = taskFlowBinding.getViewPort().getTaskFlowContext().getTaskFlowId();

    //Get the definition of the currently running task flow by its Id
    //and return its display name
    return metadataService.getTaskFlowDefinition(taskFlowId).getDisplayName();

The getTaskFlowDisplayName() method uses some helper method getTaskFlowBinding() returning a task flow binding defined in our page definition file:

private DCTaskFlowBinding getTaskFlowBinding() {
  BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();

  //taskflowdefinition1 is Id of the task flow binding in the page def file
  //like  <taskFlow id="taskflowdefinition1" ...
  DCTaskFlowBinding dtb = (DCTaskFlowBinding) ((DCBindingContainer) bc).findExecutableBinding("taskflowdefinition1");

  return dtb;

And a code snippet for our region should look like this:

<af:region value="#{bindings.taskflowdefinition1.regionModel}"

That's it!

No comments:

Post a Comment

Post Comment