This post is part of a series on building a custom worklist for BPM/SOA 11g.
In this post we will implement a Controller to take an action on a task, or to ‘process’ the task. Like the Add Comment Controller in the previous post, this controller is also fairly straightforward and does not have an associated View of its own, we will send the user back to the Task Details View for the task in question.
Here is the code for com.oracle.ateam.ProcessTaskController (with some comments removed – they are available in Subversion):
package com.oracle.ateam;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.oracle.ateam.util.MLog;
import com.oracle.ateam.domain.MTaskList;
import com.oracle.xmlns.bpmn.bpmnprocess.createtesttasks.CreateTestTasksPortType;
import com.oracle.xmlns.bpmn.bpmnprocess.createtesttasks.CreateTestTasksService;
public class ProcessTaskController extends SimpleSuccessFailureController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception {
MLog.log("ProcessTaskController", "Entering handleInternalRequest()");
String taskNumber = request.getParameter("x_tasknumber");
String action = request.getParameter("x_action");
if ((taskNumber == null) || (action == null))
return (new TaskListController()).handleRequest(request, response);
MLog.log("ProcessTaskController", "Got request to " + action + " task " + taskNumber);
MTaskList.processTask(request.getUserPrincipal().getName(), taskNumber, action);
return (new TaskListController()).handleRequest(request, response);
}
}
This again follows the same pattern. We retrieve x_tasknumber and x_action from the request – they were put there by the HTML FORM we created in the Task Display View, then we check we have valid data and call the processTask() method on our MTaskList domain object and forward the user to the Task Details Controller/View.
In the next post, we will implement Controllers and a View to initiate a task (and a process).
