Both Column Type settings use a method in a Java Program Object (JPO) to obtain the column data. The input to the JPO method that produces the column data must be a HashMap, which contains a MapList (list of object ids) and a HashMap (request parameters). Most table columns need to get a specific set of data for each object, do some processing on the data, and then add the processed data to the result set. To accomplish this with the minimum number of calls to the database, use the Studio Customization Toolkit method BusinessObject.getSelectBusinessObjectData(...). Use this method, available in Studio Customization Toolkit 9.5.3.0 and higher, instead of the deprecated context.getSelectBusinessObjectData method.
Parse this output data and process it as required. Add it to the resulting column values before returning from the JPO. Using this method, you make only one database call to get the complete set of data required to process the entire column.
To see a sample JPO program that uses the getSelectBusinessObjectData method, refer to the next section. Sample JPO for Getting Table Column Values The following is a sample Java Program Object (JPO) that retrieves the current vault for each object in the list in table rows. You can use this kind of JPO when the Column Type setting for a table column is set to program or programHTMLOutput. The method getVault in this program processes the object list and returns the vault values. For recommendations on improving the performance of programmatic table columns, see Improving Performance of Table Columns. The vault names can be obtained by configuring the table column as businessobject select expression vault instead of defining the Column Type=program. The vault example is used for simplicity and to illustrate the steps involved in writing the JPO for a table column. /* * emxTableProgram * * Copyright (c) 1992-2002 MatrixOne, Inc. * * All Rights Reserved. * This program contains proprietary and trade secret information of * MatrixOne, Inc. Copyright notice is precautionary only and does * not evidence any actual or intended publication of such program. * * static const char RCSID[] = $Id: Exp $ */ import matrix.db.*; import matrix.util.*; import java.io.*; import java.util.*; import com.matrixone.framework.beans.*; import com.matrixone.framework.util.*; import com.matrixone.framework.ui.*; /** * @version AEF 9.5.0.0 - Copyright (c) 2002, MatrixOne, Inc. */ public class ${CLASSNAME} { /** * * @param context the Matrix <code>Context</code> object * @param args holds no arguments * @throws Exception if the operation fails * @since AEF 9.5.0.0 * @grade 0 */ public ${CLASSNAME} (Context context, String[] args) throws Exception { if (!context.isConnected()) throw new Exception("not supported on desktop client"); } /** * This method is executed if a specific method is not specified. * * @param context the Matrix <code>Context</code> object * @param args holds no arguments * @returns nothing * @throws Exception if the operation fails * @since AEF 9.5.0.0 */ public int mxMain(Context context, String[] args) throws Exception { if (!context.isConnected()) throw new Exception("not supported on desktop client"); return 0; } /** * get Vault for the objects. * * @param context the Matrix <code>Context</code> object * @param args holds the following input arguments: * 0 - HashMap programMap * @returns vector of Vault names * @throws Exception if the operation fails * @since AEF 9.5.0.0 */ public static Vector getVault(Context context, String[] args) throws Exception { HashMap programMap = (HashMap) JPO.unpackArgs(args); MapList relBusObjPageList = (MapList)programMap.get("objectList"); HashMap paramMap = (HashMap)programMap.get("paramList"); Vector vaultList = new Vector(); StringList listSelect = new StringList(1); listSelect.addElement("vault"); String objIdArray[] = new String[relBusObjPageList.size()]; if ( relBusObjPageList != null) { for (int i = 0; i < relBusObjPageList.size(); i++) objIdArray[i] = (String)((HashMap)relBusObjPageList.get(i)).get("id"); // get the vault for the object BusinessObjectWithSelectList vaultSelectList = null; vaultSelectList = BusinessObject.getSelectBusinessObjectData(objIdArray, listSelect); for (int i = 0; i < relBusObjPageList.size(); i++) { String vaultName = vaultSelectList.getElement(i).getSelectData("vault"); vaultList.add(vaultName); } } return vaultList; } } |