如何获取所选项目是列表、组合框等?
我在这里找到了这段代码:
/*****
*** getSelectableValues()
*** prints all selectable values for a given component, f.e. comboboxes, listboxes etc.
***
*** @params id of component
*****/
function getSelectableValues( id ) {
var ComboBox = getComponent( id );
var ChildrenList:java.util.ListIterator;
ChildrenList = ComboBox.getChildren().listIterator();
while (ChildrenList.hasNext()) {
var Child = ChildrenList.next();
/*** process computed / multiple values ***/
if( typeof( Child ) == 'com.ibm.xsp.component.UISelectItemsEx' ){
var hlp = Child.getValue();
for( var i=0; i< hlp.length; i++ ){
/*** print to server console ***/
print( hlp[i].getLabel() + "|" + hlp[i].getValue() );
}
}
/*** process single values ***/
if( typeof( Child ) == 'com.ibm.xsp.component.UISelectItemEx' ){
/*** print to server console ***/
print( Child.getItemLabel() + "|" + Child.getItemValue() );
}
}
}
/*** get all selectable values for element 'comboBox1' ***/
getSelectableValues( 'comboBox1' );
但它似乎获得了列表框中的所有项目,而不仅仅是选定的项目。任何想法如何修改它以获取选定的值?