Code review

Custom JSPs in BPC Explorer

The Business Process Choreographer Explorer allows to include custom JSP definitions in its dialog pages. Because the custom JSP definitions are inserted into the JSP pages rendered by the BPC Explorer, these custom JSP definitions should produce HTML fragments rather than complete HTML pages. This principle is illustrated in the following image. The parent page provides an HTML form and thereby allows to embed custom HTML input elements.

The next chapters explain how input data can be accessed and how input elements for output data can be provided.

Accessing input data from the input JSP

Basically, there are two ways to access input data in a custom JSP: Expression Language (EL) expressions and request attributes. EL expressions can be included in the custom JSP code. EL enables access to particular input values using an XPath style expression.

EL: particular parameters:

${messageMap['/selectPromotionalGiftRequest/name']}

Request attribute:

The input message can be obtained as DataObject (class name commonj.sdo.DataObject):

commonj.sdo.DataObject msg = (commonj.sdo.DataObject)request.getAttribute("message");

The complete message map is also provided as request attribute:

java.util.Map msgMap = (java.util.Map)request.getAttribute("messageMap");

The keys of the message map are String objects representing XPath expressions, the values in the map are the data values in their String representation.

Accessing input data from the output JSP

If you want to access input data from the output JSP, you have to transport the data explicitly from the input JSP to the output JSP. The JSTL library offers a convenient way to transfer data between JSPs:

Add JSTL tag library:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Input JSP - store message map in the session:

<c:set var="inputData" value="${messageMap}" scope="session" />

Output JSP - access the session to get the complete message map:

Map inputData = (Map)session.getAttribute("inputData");

Accessing output data from the output JSP

You can access output data stored in the human task, either via message map or via request attributes:

EL: particular parameters:

${messageMap['/selectPromotionalGiftResponse/address']}

Request attribute:

commonj.sdo.DataObject msg = (commonj.sdo.DataObject)request.getAttribute("message");

java.util.Map msgMap = (java.util.Map)request.getAttribute("messageMap");

Read only mode

You may want to consider that your custom output JSP can be displayed in different modes that depend on the state of the human task. If the task is in claimed state, the output data can be modified. If it is in finished state, no modifications are allowed. You can query that mode and find out whether a JSP is rendered in read-only mode or in read/write mode, by using the following JSTL case statement:

<c:choose>
    <c:when test="${not empty prefix}">
        <!-- Read/write mode -->
    </c:when>
    <c:otherwise>
        <!-- Read only mode -->
    </c:otherwise>
</c:choose>

HTML form tags

The output JSP is surrounded by an HTML form, so input elements can be easily added. The name of the input element must match the XPath expression of the data element. It is important to prefix the name of the input element, thereby using the application's prefix value provided by the infrastructure in the request attribute prefix:

<input id="address"
       type="text"
       name="${prefix}/selectPromotionalGiftResponse/address"
       value="${messageMap['/selectPromotionalGiftResponse/address']}"
       size="60"
       align="left" />

The prefix value is also provided as request attribute in the HTTP request and can be queried like this:

String myPrefix = (String)request.getAttribute("prefix");

Sample JSP files

The following input and output JSP files are used in this sample in order to customize the user interface of the human task: