use of com.qwest.mbeng.NodeFinder in project mdw-designer by CenturyLinkCloud.
the class SwingFormGenerator method getChoices.
private SelectOption[] getChoices(MbengNode node) throws Exception {
SelectOption[] options;
String av = node.getAttribute(FormConstants.FORMATTR_CHOICES);
if (av != null && av.length() > 0) {
if (av.startsWith("$$.")) {
if (atRuntime) {
NodeFinder nodeFinder = new NodeFinder();
String path = av.substring(3).replaceAll("\\.", "/");
MbengNode choicesNode = nodeFinder.find(dataxml.getRootNode(), path);
if (choicesNode == null) {
options = new SelectOption[0];
} else {
ArrayList<SelectOption> list = new ArrayList<SelectOption>();
MbengNode choiceNode = choicesNode.getFirstChild();
while (choiceNode != null) {
SelectOption o = new SelectOption();
String v = choiceNode.getValue();
int k = v.indexOf(':');
if (k >= 0) {
o.value = v.substring(0, k);
o.label = v.substring(k + 1);
} else
o.value = o.label = v;
o.selected = false;
list.add(o);
choiceNode = choiceNode.getNextSibling();
}
options = list.toArray(new SelectOption[list.size()]);
}
} else
options = string2options("dynamically,generated");
} else
options = string2options(av);
} else {
options = string2options("red,green,blue");
}
return options;
}
Aggregations