December 19, 2014
Hot Topics:

Three Workflow Approaches with WebLogic Portal

  • August 4, 2008
  • By Scott Nelson
  • Send Email »
  • More Articles »

Although the disclaimers usually start later, this article merits one up front: These are not the only solutions to creating workflows in WLP. For example, you're not even going to touch on JSF, or consider the possibility of special considerations in a federated portal architecture. So, don't let yourself be limited by the scope of this article or author's experiences and prejudices. What you will examine is some solutions that are known to work and should give you enough of the basics to implement any set of workflow requirements on WLP.

Simple Page Flows

Page flows provide a very straightforward approach to creating a workflow. Using the built-in wizard will quickly generate your page flow controller with the default begin action. This default action is a simple action that doesn't do much for flow; all it does is forward to the generated index.jsp.



Click here for a larger image.

Figure 1: Default Generated Page Flow

This is quickly enhanced by right-clicking begin action under the Actions folder in the page flow perspective and selecting Convert to a Method.

@Jpf.Action(forwards =
   { @Jpf.Forward(name = "default", path = "index.jsp") })

public Forward begin() 
{
   return new Forward("default");
}

Now, you can begin adding workflow logic to your page flow. This approach is good for a simple process where the user will enter data in multiple forms and each submit does some level of processing on new data entered. You can even provide branching logic, forwarding to an action based on inputs. In either case, a single form bean in the page flow controller serves well to maintain the values, placing "frozen" values into hidden fields to maintain them from page to page and action to action.

The following is a series of action stubs that follow a simple workflow to create a web site user account:

/**
 * Check if existing first, last, and email
 * @param form userDataFormBean
 * @return success if new user, error if existing user
 */
@Jpf.Action(forwards =
   { @Jpf.Forward(name = "success", path = "creatUserName.jsp"),
     @Jpf.Forward(name="error", path="index.jsp")
})
public Forward processUserNameAndEmail(userDataFormBean form)
{
   Forward forward = new Forward("success");
   return forward;
}

/**
 * create user name and request address information
 * @param form userDataFormBean
 */
@Jpf.Action(forwards = { @Jpf.Forward(name = "success",
   path = "getAddress.jsp")
})
public Forward createUserName(userDataFormBean form)
{
   Forward forward = new Forward("success");
   return forward;
}

/**
 * Save the snail mail address and offer to subscribe
 * @param form userDataFormBean
 */
@Jpf.Action(forwards = { @Jpf.Forward(name = "success",
   path = "subscribeNewsletter.jsp")
})
public Forward storeAddressInfo(userDataFormBean form)
{
   Forward forward = new Forward("success");
   return forward;
}

/**
 * Save the subsription choice and send to summary page
 * @param form userDataFormBean
 */
@Jpf.Action(forwards = { @Jpf.Forward(name = "success",
   path = "summaryPage.jsp")
})
public Forward offerSubscription(userDataFormBean form)
{
   Forward forward = new Forward("success");
   return forward;
}

What makes this simple is that each JSP uses the same form bean, with the action set to the next action. In a more robust implementation, each action would also have an error page to forward to; this easily could be the JSP that submitted the information (such as processUserNameAndEmail does) with error messages. This example could be expanded with some simple branching; such as, if the user already exists in the database, the page flow action could forward to a password reminder page instead of simply going back to the index page.





Page 1 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel