Pre Process JPO for an Editable Structure Browser

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

This example invokes the emxIndentedTable.jsp with preProcessJPO:

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

If both a preProcessURL and preProcessJPO are specified, the preProcessURL is processed first, then the preProcessJPO is processed.

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 column 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.

You can read the arguments passed for the pre process JPO as given 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 Pre Process URL for an Editable Structure Browser, 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 (as would likely be 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 closes.

Default = CONTINUE.

Message

Either a string resource key or an original text message to display 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 contain the editable setting value based on the reserve status.

If the value of the Action key is Continue, then the system displays the standard edit page. If the value of the Action key is Stop, then the system does not display the standard edit page.

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 form page displays (if Action is Continue) or the blank form is closed (if Action is Stop).

When the blank window is closed (when Action=STOP; Message contains a value), the onUnload event (cancelProcessJPO or cancelProcessURL) should not be called.