Preprocess URL for an Editable Table

The preProcessURL parameter specifies the name of the JSP to call during pre-processing of the table in edit mode.

The following examples show how to invoke the emxTable.jsp with preProcessURL:


  1. Set the href of any command object using macros as appropriate:
    ${COMMON_DIR}/emxTable.jsp?mode=Edit&table=<table_name>
    &preProcessURL=${SUITE_DIR}/emxCustomPreProcess.jsp
    

    or

  2. Invoke emxTable.jsp with custom JSP pages using the relative path, (macros are not supported):
    ../common/emxTable.jsp?mode=Edit&table=<table_name>
    &preProcessURL=../<Application Directory>/emxCustomPreProcess.jsp
    

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

The pre process JSP supports the following input parameters:


  • The request parameters available to the emxTable.jsp, for example, timeStamp, portalMode, suiteKey, etc.
  • The request parameter timeStamp gets the table data stored in the table bean as a map.
  • To update or interact with any objects, obtain the context from the request like this:
context = (matrix.db.Context)request.getAttribute("context");

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.

The following code sample shows how to read custom processing page values from the requestMap:

<%
    // get the timeStamp from the incoming HttpRequest
    String timeStamp = (String) emxGetParameter(request,"timeStamp");

    // define the table bean
%>
    <jsp:useBean id="tableBean" 
class="com.matrixone.apps.framework.ui.UITable" scope="session"/>
<%

    // get the tableDataMap and the requestMap from the table bean
    HashMap tableDataMap = (HashMap) tableBean.getTableData(timeStamp);
    HashMap requestMap = (HashMap) 
tableBean.getRequestMap(tableDataMap);

    // get specific values from the requestMap
    String languageStr = (String) requestMap.get("languageStr");
    String timeZone = (String) requestMap.get("timeZone");
    String charSet = (String) requestMap.get("charSet");
    String suiteKey = (String) requestMap.get("suiteKey");
    String stringResourceFile = (String) 
requestMap.get("StringResourceFileId");
%>

This code sample shows how a custom processing page can iterate through the table objectIds. This example 'reserves' all objects in the objectList (typically done in a pre processing custom JSP page). Note that custom processing JSP pages do not return anything to the component.

<%
    // get the timeStamp from the incoming HttpRequest
    String timeStamp = (String) emxGetParameter(request,"timeStamp");

    // define the table bean
%>
    <jsp:useBean id="tableBean" 
class="com.matrixone.apps.framework.ui.UITable" scope="session"/>
<%
    // get the tableDataMap and the objectList from the table bean
    HashMap tableDataMap = (HashMap) tableBean.getTableData(timeStamp);
    MapList objectList = (MapList) 
tableBean.getObjectList(tableDataMap);

    // 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);

    }
%>