Sample JPO for Web Form with Custom Combobox

This section provides a sample JPO for a web form that uses a custom combobox.

import matrix.db.*;
import matrix.util.*;
import java.io.*;
import java.util.*;
public class ${CLASSNAME} 
{
    public ${CLASSNAME} (Context context, String[] args) throws Exception
    {
    }
public String getChoicesHTML(Context context, String[] args) throws Exception
{
// check String[] args passed in to tell if view or edit?
System.out.println("Array length = " + args.length);
HashMap myMap = (HashMap) JPO.unpackArgs(args);
HashMap requestMap = (HashMap) myMap.get("requestMap");
/*
System.out.println("\ntags within HashMap.................: " + requestMap  + "\n");
*/
//Edit mode:
// this should return "edit" if "edit" then build combobox else just display value for 
view mode
String  edit = (String) requestMap.get("mode");
String sReturn = "";
if (edit == null ) // display value for view mode in webform
{
  sReturn ="3";
  System.out.println("mode not edit");
} 
else // display list of values in combo box for edit mode 
{
 System.out.println("mode IS edit");
 sReturn = "<SELECT name=\"test\"> <OPTION>1 <OPTION>2 <OPTION SELECTED>3 <OPTION>3 
<OPTION>4 <OPTION>5  </SELECT>";
}
// Your webform field needs these settings
// Field Type=programHTMLOutput
// function=JPOMethodName
// program=JPOName
// Watch the spelling and case of the above settings!
// To actually save the value selected you would have to add the following settings with 
a new save method
// Update Function=JPOMethodName
// Update Porgram=JPOName
// the data to be save will be in the requestMap similar to above
// this returns the String needed to display the custom HTML combo with 3 SELECTED as 
default
return sReturn;
}
public static Object getChoices(Context context, String[] args) throws Exception
{
System.out.println("inside getChoices2 method");
HashMap programMap = (HashMap) JPO.unpackArgs(args);
StringList fieldRangeValues = new StringList();
// Get the required parameter values from  "programMap" - as required
String  objectId = (String) programMap.get("objectId ");
String  relId = (String) programMap.get("relId ");
String  requestQueryString = (String) programMap.get("requestQueryString");
String  languageStr = (String) programMap.get("languageStr");
fieldRangeValues.addElement("test2_1");
fieldRangeValues.addElement("test2_2");
fieldRangeValues.addElement("test2_3");
fieldRangeValues.addElement("test2_4");
fieldRangeValues.addElement("test2_5");
System.out.println("done adding elements");
return fieldRangeValues;
}
}