Enabling business process portlets that use the Basic portlet model

Portlets created using the Basic code generation model option require additional enablement to handle business processes.

When creating a business process portlet using the New Portlet Project wizard or New Portlet wizard, you can specify either a Faces or a Basic portlet model to generate code for process initiation or task processing. However, for a Basic portlet, after the wizard generates the base code, there are additional steps that you must perform to enable the business process portlet.
  1. To enable a process initiation portlet, follow these steps:
    1. Create user interface for an input message in the portlet JSP file. For example, add a <form> tag with <input> tags for the input message, and an action URL.
    2. Implement processAction() (JSR 168 API) or actionPerformed() (IBM® portlet API) to store request parameter values in corresponding parts of the input message.
      Note: If the input message has message parts that are complex types, request parameters must be stored in a complex type created and stored to the corresponding message part. Refer to the example below.
    3. Call initiateProcess() in processAction() (JSR 168 API) or actionPerformed() (IBM portlet API). For example:
      public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
        if( request.getParameter("initiateProcess") != null ) {
          PortletSession session = request.getPortletSession();
          Map inputMessage = (Map)session.getAttribute(ProcessInitiationHelper.PROCESS_INPUT_MESSAGE);
          inputMessage.put("Destination", request.getParameter("Destination"));
          inputMessage.put("StartDate", request.getParameter("StartDate"));
          inputMessage.put("Reason", request.getParameter("Reason"));
          FlightReservation flightReservation = new FlightReservation();
          flightReservation.setStartdate(request.getParameter("FlightReservation.startdate"));
          flightReservation.setStarttime(request.getParameter("FlightReservation.starttime"));
          flightReservation.setEnddate(request.getParameter("FlightReservation.enddate"));
          flightReservation.setEndtime(request.getParameter("FlightReservation.endtime"));
          flightReservation.setSourceairport(request.getParameter("FlightReservation.sourceairport"));
          flightReservation.setDestinationairport(request.getParameter("FlightReservation.destinationairport"));
          flightReservation.setAirline(request.getParameter("FlightReservation.airline"));
          flightReservation.setSeatclass(request.getParameter("FlightReservation.seatclass"));
          inputMessage.put("FlightReservation", flightReservation);
          Employee requestor = new Employee();
          requestor.setId(request.getParameter("Requestor.id"));
          inputMessage.put("Requestor", requestor);
          ProcessInitiationHelper helper = getProcessInitiationHelper(request);
          helper.initiateProcess();
        }
      }
  2. To enable a task processing portlet, follow these steps:
    1. Create user interfaces for the input and output messages in the portlet JSP file. For example, add a <form> tag with <input> tags for the input message, and an action URL.
    2. Implement processAction() (JSR 168 API) or actionPerformed() (IBM portlet API) to store request parameter values in corresponding parts of the output message.
      Note: If the input message has message parts that are complex types, request parameters must be stored in a complex type created and stored to the corresponding message part.
    3. Call processTask() and, optionally, closePage(), in processAction() (JSR 168 API) or actionPerformed() (IBM portlet API). For example:
      public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
        TaskProcessingHelper taskProcessingHelper = getTaskProcessingHelper(request);
        if (taskProcessingHelper != null)
          taskProcessingHelper.receivePageContext(request);
        if( request.getParameter("processTask") != null ) {
          PortletSession session = request.getPortletSession();
          Map outputMessage = (Map)session.getAttribute(TaskProcessingHelper.TASK_OUTPUT_MESSAGE);
          outputMessage.put("Worker", request.getParameter("Worker"));
          outputMessage.put("managerApproved", new Boolean(request.getParameter("managerApproved") != null));
          taskProcessingHelper.processTask();
          taskProcessingHelper.closePage(request, response);
        }
      }
Related concepts
Process initiation helper classes
Task processing helper classes
Related tasks
Creating a business process portlet project
Developing business process portlets
Adding data access to business process portlets
Related reference
WebSphere Portal Documentation Library
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.