Implementing Add Comments

This post is part of a series on building a custom worklist for BPM/SOA 11g.

We just have a Controller to add comments to a task, no View.  After adding comments to a task, we will return the user to the Task Details View for that task.  This controller will be called (invoked) from an HTML FORM on the Task Details View, as we saw in the last post.

Here is the code for the Add Comments Controller,, I left some of the comments in here, but there are more in the file in Subversion.


import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AddCommentController extends SimpleSuccessFailureController {

  @Override  protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    MLog.log("AddCommentController", "Entering handleInternalRequest()");

    // retrieve details from the request to identify the task and comment
    String taskNumber = request.getParameter("x_tasknumber");
    String comment = request.getParameter("x_comment");

    // check that data was provided
    if ((taskNumber == null) || (comment == null))
       return (new TaskDetailController()).handleRequest(request, response);

    // add the comment to the task
    MTaskList.addComment(request.getRemoteUser(), taskNumber, comment);

    // send the user back to the task detail page (where they came from)
    return (new TaskDetailController()).handleRequest(request, response);

This Controller follows the same pattern as the others we have seen already: retrieve information that the caller placed in the request, in this case the x_tasknumber to identify the task and x_comment with the text of the new comment, check we have valid data, then call a method on our MTaskList object, in this case addComment(), to carry out the ‘business logic’, and then forward the user to the next view, in this case to the TaskDetailController.

Spring provides us with the ability to chain Controllers together like this, so that a user request can in fact pass through several Controllers to be handled.

That’s all for the Add Comment Controller!

In the next post, we will the Controller to process actions on a task.

About Mark Nelson

Mark Nelson is an Architect (an "IC6") in the Fusion Middleware Central Development Team at Oracle. Mark's job is to make Fusion Middleware easy to use in the cloud and at home, for developers and operations folks, with special focus on continuous delivery, configuration management and provisioning - making it simple to manage the configuration of complex environments and applications built with Oracle Database, Fusion Middleware and Fusion Applications, on-premise and in the cloud. Before joining this team, Mark was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

One Response to Implementing Add Comments

  1. Pingback: Implementing Add Comments

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s