Get selectable values of a component


/*****
 *** 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' );
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...