You are here

WebCenter Portal Tutorial part 6: Building a taskflow and consuming it in WebCenter Portal

It's been a while since I wrote my last part of this tutorial so it's about time I continued with it. Meanwhile I got some great ideas for additional content of this tutorial so keep supporting it and I will keep posting it!

In this part I will show you how we can build a taskflow in a separate application and then import that taskflow into our WebCenter portal application. The taskflow will display a simple form so people can register themselves to our portal. The form will contain a username and password field. We will do simple checks like password and password confirmation check and display a message when the user already exist.

Before we begin, a small disclaimer: the code provided to create a user will only work to create a user in the default security realm of a WebLogic server. If you are using OID or any other external provider, the code provided in this tutorial will no longer work. The aim of this tutorial is to show how to separate the taskflows from your portal and how to include them into your portal application.

That said, let's get to work.

Creating the Register Taskflow

The first part of this tutorial will be about the creation of the Register taskflow. Let's start by creating a new Fusion Web application. Yes, that's right. A regular Fusion Web Application, no WebCenter Portal Application:

Specify the name and package

We won't be needing the Model project so just leave these as the default value.

It is a good practice to change the ViewController to something more meaningfull so specify RegisterView as the project name:

Press Finish to complete the creation.

Right click the WEB-INF folder and select New.

Select JSF from the list on the left and ADF Task Flow on the right:

Press OK and specify registerTF.xml as the filename. Make sure that the checkbox Create as Bounded Task Flow is checked. The difference between a Bounded and Unbounded taskflow is that a Bounded Taskflow has a single point of entry and can have multiple exit points. An Unbounded taskflow can have multiple entry points. By default, JDeveloper will create an Unbounded taskflow when you create a Fusion Web Application. The definition can be found in the adfc-config.xml. This is not really important for WebCenter but I just wanted to give you some background information about this...

Press the OK button to create the taskflow.

Our Register taskflow will be a very simple taskflow. It will only have a single view in its definition. So drop the View component from the Component Palette on the Diagram of the taskflow and change the name to register:

The green background circle means that the register view is the default activity. This activity will be executed when the taskflows renders. The warning is displayed because we didn't bind the view component to an actual fragment so double click on the register view. This will open the Create New JSFF page fragment wizard.

The filename will be set to the name of the view which is fine. Change the folder so it ends on \register as shown in the image:

Personally I find it good practice to create a folder for each taskflow to group the fragments of the same taskflow together.

Before we add some components to the register fragment we need to create a managed bean to store our code in.

right click on the RegisterView project and select New. Select General in the left menu and Java Class in the right list.

Name the class RegisterBean and specify a class:

Press OK to create the Java Class.

Add a username, password, passwordConfirm string to the class and create the accessors.

Create the createUser method in the class with following code:

  1. public boolean createUser(String username,String password){
  2.   try {
  3.    JpsContextFactory jps = JpsContextFactory.getContextFactory();
  4.    JpsContext jpsContext = jps.getContext();
  5.    IdentityStoreService storeService = jpsContext.getServiceInstance(IdentityStoreService.class);
  6.    IdentityStore is = storeService.getIdmStore();
  7.    UserManager mn = is.getUserManager();
  8.    RoleManager rm = is.getRoleManager();
  9.    Principal p = mn.createUser(username,password.toCharArray()).getPrincipal();
  10.    Role r = is.searchRole(is.SEARCH_BY_NAME, "member");
  11.    rm.grantRole(r, p);
  12.    return true;
  13.  }
  14.  catch(Exception e) {
  15.      System.out.println(e.getMessage());
  16.      e.printStackTrace();
  17.     return false;
  18.  }
  19. }

This method will create the user in the security realm of your WebLogic server. As you can see from one of the last lines of code, we also grant the user a role. This is required to allow the user to authenticate. Before this code can compile, we need to setup security to our application. This is done. This is done by selecting Application => Secure => Configure ADF Security:

Because we only need the libraries and the actual security is not really important, we can just press Finish and keep the defaults. The WebCenter Portal will contain the actual security settings. This is setup by default so you don't have to worry about that.

A next step is to create the role that we assign to the user. This is done in the WebLogic console so make sure your Integrated WLS is running and browse to http://localhost:7101/console

Login to the console and select security realm in the domain structure in the left hand side. Select myrealm.

Select the Users and Groups tab and select the Groups tab:

Click on the New button to create a new group. Specify member as the name and press OK:

This will create the group in the security realm so we can assign this by using our method from above. Notice that the group name is the same as the role name specified in the code!

The taskflow will display a link to register which will open a popup that displays the form. The popup uses a dialog so we need to have a dialogListener to handle the dialog events:

  1. public void diagRegister(DialogEvent e) {
  2. if(e.getOutcome() == DialogEvent.Outcome.ok ||
  3.     e.getOutcome() == DialogEvent.Outcome.yes){
  4.   String userCreated = "User has been created, you can now login.";
  5.   String userFail = "Passwords do not match, please check";
  6.   if(passwordConfirm.equals(password))
  7.      if(createUser(username,password)){
  8.        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO,
  9.                                   userCreated,userCreated);
  10.        FacesContext context = FacesContext.getCurrentInstance();
  11.        context.addMessage(userCreated, message);
  12.      }
  13.      else {
  14.        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
  15.                         userFail,userFail);
  16.        FacesContext context = FacesContext.getCurrentInstance();
  17.        context.addMessage(userFail, message);
  18.      }
  19.  }
  20. }

This method will check if the OK button is clicked. If so, it will create the user by calling the createUser method and display the message to the user so he knows he can login. If there was an issue, the user will see a message that the registration has failed.

That's it for java code for now. Let's register the bean to our taskflow. Open the registerTF.xml and open the Overview. In the Managed Beans section press the Add button and specify following values for the managed bean:

Save the taskflow.

Now we can finally create the code for the register.jsff fragment.

We add a commandLink to open a popup and the popup will contain the form for username, password and passwordConfirm:

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <jsp:root xmlns:jsp="" version="2.1"
  3.          xmlns:af="">
  4.   <af:group id="gContainer">
  5.   <af:commandLink text="Register" id="cmdRegister">
  6.         <af:showPopupBehavior triggerType="action"
  7.            popupId="popRegister"/>
  8.   </af:commandLink>
  9.   <af:popup id="popRegister" contentDelivery="lazyUncached">
  10.    <af:dialog id="dlgRegister" title="Register"
  11.              dialogListener="#{registerBean.diagRegister}">
  12.     <af:panelFormLayout id="fRegister">
  13.         <af:inputText id="txtUser" label="Username"
  14.            value="#{registerBean.username}" required="true" />
  15.         <af:inputText secret="true" id="txtPass" label="Password"
  16.           value="#{registerBean.password}" required="true"/>
  17.         <af:inputText secret="true" id="txtPass2" label="Confirm Password"
  18.          value="#{registerBean.passwordConfirm}" required="true"/>
  19.     </af:panelFormLayout>
  20.     </af:dialog>
  21.   </af:popup>
  22.   </af:group>
  23. </jsp:root>

That's it. Now we can deploy this taskflow as a library so we can use it in WebCenter.

If you want to consume taskflows from other applications, you need to deploy those applications/taskflows as an ADF Library JAR so we need to create a special deployment profile for this.

This can be done by right clicking on the RegisterView project and select Project Properties

Select Deployments and click the New button on the right hand side.

Select ADF Library JAR File as the archive type and specify a name for the profile:

Press OK to create the profile. Press OK in the next window to keep the defaults.

You now have two profiles:

Let's deploy the taskflow. This will actually not deploy the taskflow to any server. It will create a JAR file instead that we can use as a reference in WebCenter Portal.

Right click on the RegisterView project, select Deploy and select the adfLibRegisterTF profile.

In the next screen you can only select Deploy to ADF Library JAR file. Press Finish to deploy to the JAR file.

Consume the Register Taskflow in WebCenter Portal

Now that we have created the Register taskflow and deployed it to a JAR file, we can consume it in WebCenter Portal.

If you got stuck in the previous section of this tutorial, you can download the RegisterTaskflow workplace from here.

First of all we need to create a File System connection to the location of the JAR file. In JDeveloper in the resource Palette right click on File System in the IDE Connections and select New File System Connection:

Specify a name for the connection and point the directory to the deployment path of the Register Taskflow project:

Make sure to point to the directory, not to the JAR file!

Press OK to create the connection.

When you open the connection you will see the jar and the taskflow:

Now we are ready to consume the taskflow.

Now it's time to open the ViePortal application. Open the VieTemplate.jspx and add a li before the logout li. Inside the new li drag and drop the registeTF from the adfLibRegisterTF we have registered in the resource palette to the VieTemplate.jspx. This will add the taskflow as a region and your code will look like this:

  1. <li><af:region value="#{bindings.registerTF1.regionModel}" id="pt_r1"/></li>

Because the WebCenter Portal application has security enabled, we need to configure which roles have access to the taskflow. When we drop the taskflow to our page, the registerTF library will be added to our project and we will be able to configure its security.

Open the jazn-data.xml from the descriptors/META-INF folder in the Application Resources. Select Resource Grants. Select Task Flows as the Resource Type and make sure you selected Show task flows imported from ADF libraries:

In the list look for registerTF. It is showing a lock icon which means that nobody can access the taskflow. Let's change this by adding the anonymous Application Role:

That's it! We are finished. Let's register a new user. Right click on the Portal project and select Run.

When the portal has started you will see the Register link on the right hand side:

Click it and it will open the Register popup:

And now I can login with my user.

That's it. As a summary of this section I will outline the steps to create and consume taskflows in WebCenter

  1. Create a Fusion Web Application
  2. Create the taskflow in that application
  3. Deploy the application as an ADF Library JAR file
  4. Create an File System connection in the IDE connections to the location of the ADF Library JAR file
  5. Drop the taskflow to your page or resource catalog
  6. Configure Resource Grants in the jazn-data.xml.

You can download the finished ViePortal for this part from here.

Hope you enjoyed this section of the tutorial. As always, the comments are open for questions and opinions.


Great Post !!! ,, but I have a question hope you can answer. I'm working with WC Spaces not a custom portal framework, so how can I deploy my task flow as we are not using a custom portal ?

Hope you can help us.

Very help full for understanding the basic, Can you share some complex scenerio

What did you get in mind?
Just give some ideas and I might add it to the tutorial.

Thanks for the reply, I am just adding some scenario, if possible you can integrate in your application.

1) bounded task flow can accept input parameters and can pass return values to the caller.
2) train-based activities in a bounded task flow, Should be reused in same or other applications.
3) Changes data and then either commits or rollbacks on exit.
4) Building task flow on a Dynamic Region.

Although most of these topics are pure ADF topics, I have some plans on integrating them into the tutorial.
I was planning on doing some taskflow that allows administrators of the portal to edit the profile of students. This will all be based upon ADF BC and the taskflow will take parameters for the students. This part will cover both your first and 3th suggestion.

Thanks, I think that will be helpful. I have a query, for last 3 month I am struggling with not able to do, I have customize ADF portal, users get authenticated from OID. Even I have webcenter space. Now I have a link inside ADF portal "Spaces", if I click that automatically user can get authenticate in Webcenter Space without asking the credentials. I have tried SAML , oracle support team but not able to execute. Can you please help me in this.

Very good blog. i didnt c befor this type of blog for webcenter portal in google.
Please add ADF BC.

Hi Yannick , Excellent post... it so helping me.
Can you add ADF business components as well..

can u explain
what JpsContextFactory ,JpsContext ,IdentityStoreService , IdentityStore inside createUser method

Thanks Yannick! Your tutorial helped me so much that I decided to buy your book to have a better understanding of all the WebCenter aspects. Keep up the good work!

Thanks Yannick ! very clear .

Excellent Post!!
With the PS2 is the same process?

To be honest, I don't exactly know...
PS2 has a completly different architecture than PS3 onwards so I would imagine this will not work for PS2.

However, jazn-data configuration is similar and creation a connection to the file system to inlcude an ADF library is also similar so it might work...

However... Adding the taskflow to the resource catalog is a completly different game. As you probably know PS2 does not have the easy way of editing the resource catalog.

Yannick, nice post!

One question, when the registerTF is updated (some labels, other TF ...).
Next time the Portal App is deployed ... the taskflows on the Jar is not updated ... is there any "step" that need to be done?
What about deploy the jar as library on WLS? how can this be re-used on the Webcenter Portal?

Pedro Ribeiro

You have to right click on your portal project and select "Refresh ADF library dependencies". This way your portal will be injected with the new JAR file.

Hi Yannick,

How do i register my custom task flow in deployed web center portal application?

I am able to do this tutorial and create users, but after i give the username, pw, and confirm pw and click ok button ... i am not getting the popup saying user has been created.. if passwords do not match also i am not getting an error saying passwords do not match but it is not creating the user in this scenario and works correctly ... only thing is in both the instances faces msg is not coming..

And also if i want to check whether the user is already there in weblogic how do i do that in this tutorial ... i have created a user by name hello... next time when i am trying to create the user with samename i am getting an error at jdev end that hello user already exists... i want to show the same in popup as a faces msg on the ui ... can you please let me know on both of these


Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer