/** * Sample option list of N items * xpath: /Options * * @param context PropertyContext * @return dom4j document */ public Document getDebugOptions(PropertyContext context) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Executing Debugging.getDebugOptions"); } Document doc = Dom4jUtils.newDocument(); Element optionsBase = doc.addElement("Options"); //a_Process parameters String str = (String)context.getParameters().get("basename"); String basename = (null == str ? "DebugItem" : str); str = (String)context.getParameters().get("start"); int startN = (null != str ? Integer.parseInt(str) : 3); str = (String)context.getParameters().get("count"); int countN = (null != str ? Integer.parseInt(str) : 3); //a_Add N options for (int i=startN; i < startN+countN; ++i) { GeneratorUtils.addOption(optionsBase, basename+i, basename+"_"+i); } return doc; }
public final class GeneratorUtils{/*** Option tag*/public static final String OPTION = "Option";/*** Option display*/public static final String OPTION_DISPLAY = "Display";/*** Option value*/public static final String OPTION_VALUE = "Value";/** No default ctor */private GeneratorUtils() {}/*** Adds an to when creating output for Generator * * @param optionsBase base element* @param display Option's display string* @param value Option's value string* @return element just added*/public static Element addOption(Element optionsBase, String display, String value){ Element option = optionsBase.addElement(OPTION); option.addElement(OPTION_DISPLAY).addText(display); option.addElement(OPTION_VALUE).addText(value); return null;}}
You can't just add a string, it has to be in a format that the calling AJAX function can use to populate the control.From Debugging class in impl.zip: /** * Sample option list of N items * xpath: /Options * * @param context PropertyContext * @return dom4j document */ public Document getDebugOptions(PropertyContext context) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Executing Debugging.getDebugOptions"); } Document doc = Dom4jUtils.newDocument(); Element optionsBase = doc.addElement("Options"); //a_Process parameters String str = (String)context.getParameters().get("basename"); String basename = (null == str ? "DebugItem" : str); str = (String)context.getParameters().get("start"); int startN = (null != str ? Integer.parseInt(str) : 3); str = (String)context.getParameters().get("count"); int countN = (null != str ? Integer.parseInt(str) : 3); //a_Add N options for (int i=startN; i < startN+countN; ++i) { GeneratorUtils.addOption(optionsBase, basename+i, basename+"_"+i); } return doc; } Code above adds random # of items.GeneratorUtils.addOption is what adds the correctly formatted option: public final class GeneratorUtils{/*** Option tag*/public static final String OPTION = "Option";/*** Option display*/public static final String OPTION_DISPLAY = "Display";/*** Option value*/public static final String OPTION_VALUE = "Value";/** No default ctor */private GeneratorUtils() {}/*** Adds an to when creating output for Generator * * @param optionsBase base element* @param display Option's display string* @param value Option's value string* @return element just added*/public static Element addOption(Element optionsBase, String display, String value){ Element option = optionsBase.addElement(OPTION); option.addElement(OPTION_DISPLAY).addText(display); option.addElement(OPTION_VALUE).addText(value); return null;}}
<DATUM><OPTION><OPTION>...</DATUM>