Code review

Custom JSPs in BPC Explorer

The BPC Explorer includes custom JSPs in its output pages. So, custom JSPs should produce only HTML fragments as illustrated in the following image. The parent page provides an HTML form in that you can embed HTML input elements.

The next chapters explain, how you can access input data and provide input elements for output data.

Accessing input data from the input JSP

Basically, there are two ways to access input data in a custom JSP: Expression Language (EL) expressions or request attributes. EL expressions can be included in your HTML code. EL enables access to particular input values using an XPath like expression. You can also receive a DataObject, if you get the data from the request attributes.

EL: particular parameters:

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

Request attribute:

You can obtain the input message as 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 have to consider, that your custom output JSP can be displayed in different modes which depend on the state of the human task. If the task is in claimed state, output data can be modified. If it is in finished state, no modifications are allowed. You can detect, if your JSP is rendered in the read/write state with 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 a 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 with the provided prefix value:

<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:

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