+

Search Tips   |   Advanced Search


Process the input and output messages of the task

Specify how the Task Processing portlet handles task input and output messages and task completion. Refer to the code samples for developing a standard portlet. You should have experience developing portlets, including cooperative portlets, using either the standard portlet API, the Task UI Manager API, the Property Broker API, and the Task API.

In developing this module of the Task Processing portlet, you specify the PortletServiceHome, the retrieval and display of the input message values of the task, the user interface for obtaining user-defined output message values, the properties exchanged with other portlets supporting the task, the user-defined output message values to the Human Task Manager service, and the completion of the task.

To specify how the Task Processing portlet handles task input and output and task completion, follow these steps and the code samples provided:

  1. Obtain an instance of the HumanTaskManagerDelegate using the HumanTaskManagerDelegateFactory.

       public void init(PortletConfig portletConfig) throws PortletException, UnavailableException
       {
          super.init(portletConfig);
    
          ...
    
          Context ctx = new InitialContext();
    
          PortletServiceHome humanTaskManagerDelegateFactoryServiceHome = (PortletServiceHome)         
                 ctx.lookup("portletservice/com.ibm.portal.portlet.service.taskmanager.HumanTaskManagerDelegateFactoryService"); 
    
           HumanTaskManagerDelegateFactoryService humanTaskManagerDelegateFactoryService = 
                    (HumanTaskManagerDelegateFactoryService)
                 humanTaskManagerDelegateFactoryServiceHome.getPortletService(HumanTaskManagerDelegateFactoryService.class);
    
           humanTaskManager = humanTaskManagerDelegateFactoryService.getHumanTaskManagerDelegate();
          ...
       } 
    
      
    

  2. Use the method getInputMessage() of the TaskManagerService interface to obtain the input message from the Human Task Manager.

    
    

    DataObject message = (DataObject) (((com.ibm.task.api.ClientObjectWrapper) taskManager.getInputMessage(taskID)).getObject());

  3. Implement user interfaces to display the input message of a task and to obtain the required data from the user for task output. As part of this step, you can also specify the exchange of properties between the Task Processing portlet and other portlets on the task page that support the work of completing the task. Use the property broker to specify how the Task Processing portlet cooperates with other portlets.

  4. Add code to store the result back to WebSphere Process Server. After the user has entered information into the portlet and submits the changes, the portlet uses the method setOutputMessage() of the TaskManagerService interface to send the information to the Human Task Manager.

       Task task = taskManager.getTask(taskID);
    
    

    ClientObjectWrapper cow = (com.ibm.task.api.ClientObjectWrapper) taskManager.createMessage(taskID, task.getOutputMessageTypeName()); DataObject message = (DataObject) cow.getObject(); message.setBoolean("managerApproved",true); taskManager.setOutputMessage(taskID, cow);

  5. Add code that completes the task. The portlet uses the complete() method of the TaskManagerService interface.

       taskManager.complete(taskID);
    
    


Parent topic:

Creating Task Processing portlets


Previous topic:

Retrieve properties from the Task List portlet


Next topic:

Close the task page