Instead of a select expression, set the "Column Type" column setting to one of the following:
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:
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:
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;
} |