Column Values as Program Output

You can obtain the column values based on specific business logic defined within a method in a Java Program Object (JPO).

Instead of a select expression, set the "Column Type" column setting to one of the following:


  • Column Type = program: Use when the program results contain only the column value.
  • Column Type = programHTMLOutput: Use when the program results contain the complete HTML tag (including the column value) to be displayed in the table column.

Both require a JPO for getting the column value results. You must configure the name of the JPO and the method for this column as settings for the table column:


  • program = JPO_NAME: The JPO program object name to get the column values.
  • function = JPO_METHOD_NAME: The JPO method name to return the results of column value.

When "columnType = program," the method that runs to get the values of the column should not have any HTML. If the method returns HTML, the same code is also written in the PrinterFriendly pages as links. For exports, the HTML tags are written to the exported file.

To return the HTML from the method, use the setting "Column Type = programHTMLOutput" instead of "Column Type = program." To get the column values exported when the Column Type is "programHTMLOutput," you must also set "Export= true" for the column.

To ensure that you do not return HTML or href links for PrinterFriendly pages and export files, the JPO method requires conditional logic to decide when to return the values with or without HTML. Use the parameter "reportFormat" (available to the JPO) for checking the condition.

For regular web page display, the reportFormat will be null or empty string. The reportFormat parameter will contain a valid value only for the export mode or Printer Friendly mode. Valid reportFormats are CSV, HTML, TXT and ExcelHTML.

The following sample code illustrates these methods:

    public static Vector functionName (Context context,String args[]) throws Exception {
              Vector retVal = new Vector();
              
              String reportFormat = (String)paramMap.get("reportFormat");
              
              String name = "name to Displayed in the column";
              String outString = "html code";
              
              for (each object) {
                      if(reportFormat != null && reportFormat.length() > 0)
                      {
outString=name;
                      } else {
outString="<a name=" + name + "href=../common/
emxTree.jsp?treeMenu=type_TechnicalSpecificationTemplate&mode=i
nsert&jsTreeID="+jsTreeID+"&objectId="+objectId+" ><img src=../
common/images/iconSmallSpecification.gif border=0>" + name + "</
a>";
                      }
    
    // If anything special has to be done for specific report formats then users can 
check reportFormat with corresponding string and write the code like the following if 
needed
    
                    if("CSV".equals(reportFormat)) {
                            //special code for CSV format
                    } else if("TXT".equals(reportFormat)) {
                            //special code for TXT format                        
                    } else if("HTML".equals(reportFormat)) {        
                            //special code for HTML format
                    } else if("ExcelHTML".equals(reportFormat)) {        
                            //special code for ExcelHTML format
                    }
    
                      
                    retVal.add(outString);
              }
              return retVal;
    }

See Improving Performance of Table Columns for a sample program to get column values when Column Type is set to program and for recommendations on improving the performance of a programmatic table column.

The JPO for the columns must follow these rules:


  • It must define a method with the exact name specified in the function column setting.
  • The method must take an input argument as a HashMasp containing details of the object list to be processed. The data structure of this input parameter (HashMap) is defined below:
    Key Name Data Type Description

    objectList

    MapList

    This MapList contains a list of HashMaps with the values of OIDs and RelIDs. Every HashMap contains the value for OID and RelID belonging to one table row. The size of the MapList passed in equals the list of rows to be presented in the table.

    The structure of each HashMap belonging to a table row is defined below:?

    Key "id" is assigned to the business object Id (OID) to be used in the current table row.

    Key "id[connection]" is assigned to the relationship id (RelID) to be used for the current row.

    paramList

    HashMap

    This HashMap contains the all the request parameter key / value pair available in the JSP page level.

    An additional parameter "languageStr" is available to the HashMap. This key is assigned to the value with current browser language setting (like en, fr, ja etc). This value may be used for the internationalization purpose within the JPO program.

  • The method must return a vector of String or StringList, containing the column values to display. The vector size must be equal to the size of the input MapList.

Here is a template for the JPO function.

public static Vector methodName(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 columnValues = new Vector(relBusObjPageList.size());
    String bArr [] = new String[relBusObjPageList.size()];
    String rArr[] = new String[relBusObjPageList.size()];
    StringList bSel = new StringList();
    StringList rSel = new StringList();
// Get the required parameter values from  "paramMap" - if 
required
String languageStr = (String)paramMap.get("languageStr");
// Get the object elements - OIDs and RELIDs - if required
for (int i = 0; i < relBusObjPageList.size(); i++)
      {
       // Get Business object Id
bArr [i] = 
(String)((HashMap)relBusObjPageList.get(i)).get("id");
// Get Relationship Id
rArr [i] = 
(String)((HashMap)relBusObjPageList.get(i)).get("id[connection]
");
    }
    // Add any Business object selects if required 
bSel.add("current");
      bSel.add("policy");
      bSel.add("attribute[Originator].value");
    // Add any Relationship selects if required 
rSel.add("attribute[Find Number].value");
    // Process the OIDs to get the results - if required
BusinessObjectWithSelectList bwsl = 
context.getSelectBusinessObjectData(bArr, bSel);
    // Process the RelIDs to get the results - if required
RelationshipWithSelectList rwsl = 
context.getSelectRelationshipData(rArr, rSel);
    // Code for processing the result data obtained - if required
    //Build the Vector "columnValues" with the list of values to 
be displayed in the column
    return columnValues;
}