Preprocess JPO for an Editable Table

The preProcessJPO parameter specifies the name of the JPO program and method to invoke during pre processing.

This example shows how to invoke the emxTable.jsp with preProcessJPO:

${COMMON_DIR}/emxTable.jsp?mode=Edit&table=<table_name>
&preProcessJPO=<JPO Name>:<Method Name>

If both a preProcessURL and preProcessJPO are specified, the preProcessURL executes first followed by the preProcessJPO.

The pre process JPO specifies the programMap as an argument for the pre processing. The programMap contains the following HashMaps:


  • requestMap contains all the request parameters
  • paramMap contains these key parameters and expected values:
    Parameter Description

    objectId

    Object ID

    relId

    Relationship ID of the object

  • tableData contains all the table information

The above maps are packed using the packArgs method supported by JPO and passed to the pre process JPO being invoked. The pre process JPO can unpack this input parameter and use it for custom coding.

If you want to manipulate only those objects selected before entering edit mode of the table, the JPO method should use the EditObjectList MapList in the tableData map. This MapList contains the objectIDs of the selected objects, while the ObjectList MapList contains the objectIDs of all objects in the table.

To display specific objects in the table as read-only, the individual ObjectMap within the ObjectList MapList must have RowEditable=readonly. This applies only to the ObjectList that the preprocessing method passes back to the table.

The RowEditable setting controls the entire row as editable or not. The row can hold data on a specific business object or relationship instance, or another set of related values. These values can come from a program which may have dependencies. Currently, the preProcess JPO does not have an interface to control which type of data is editable or non-editable within a row.

You can read the arguments passed for the pre process JPO as shown below:

HashMap programMap = (HashMap) JPO.unpackArgs(args);
HashMap paramMap = (HashMap) programMap.get("paramMap");
HashMap requestMap = (HashMap) programMap.get("requestMap");
HashMap tableMap = (HashMap) programMap.get("tableMap");

The requestMap contains the languageStr. You can read the value as shown below:

String languageStr = requestMap.get("languageStr");

The JPO can use the same method as described in Preprocess URL for an Editable Table, to get the objectList, or it can obtain them from the programMap that the table component passes to the JPO. The following code sample shows how a custom processing JPO can iterate through the table objectIds. This example reserves all of the objects in the objectList (typically done in a preprocessing JPO):

    // unpack the incoming arguments into a HashMap called 'programMap'
    HashMap programMap = (HashMap)JPO.unpackArgs(args);
    // get the 'tableData' HashMap from the programMap HashMap

    HashMap tableData = (HashMap) programMap.get("tableData");
    // get the 'objectList' MapList from the tableData HashMap
    MapList objectList = (MapList) tableData.get("ObjectList");
    // loop through the objectList's list of object Maps
    Iterator objectListItr = objectList.iterator();
    while(objectListItr.hasNext()){

       // get the current object Map
       Map curObjectMap = (Map) objectListItr.next();
       // get the current object's objectId from the current object Map
       String curObjectId = (String) curObjectMap.get("id");
       // a comment to pass along with the object reserve operation
       String reserveComment = "This object is Reserved";

       // create a BusinessObject, open the object, reserve the object, 
close the object
       BusinessObject curBusObject = new BusinessObject(curObjectId);
       curBusObject.open(context);
       curBusObject.reserve(context,reserveComment);
       curBusObject.close(context);

    }

The pre process JPO returns a HashMap containing the keys defined in this table.

Key Value

Action

Assigned to one of these values:

CONTINUE - the process continues

STOP - the process stops and the edit dialog is closes.

Default = CONTINUE.

Message

Either a string resource key or an original text message to be displayed to the user. The string must use proper JavaScript format for escape characters such as single quote, double quote, and new lines.

ObjectList

The MapList of object maps that contains the RowEditable setting value based on the reserve status. See the MQL Guide for details on reserving objects.

If the value of the Action key is CONTINUE, then the standard edit page displays. If the value of the Action key is STOP, then the standard edit page does not display.

If the MESSAGE key contains a value, it displays to the user as an alert message on top of the editable page (which is blank if the Action is Stop). When the user clicks OK in the message dialog, then the editable table page displays (if Action is Continue) or the blank page is closed (if Action is Stop).

When the blank window is closed (when Action=STOP; MESSAGE contains a value), do not call the onUnload event (cancelProcessJPO or cancelProcessURL).