WebSelect

General

A WebSelect is a graphical component which displays a list of items either as a pop-up menu of choices (dropdown) or as a scrolling, multi-line list (listbox). The currently selected item is highlighted.

When a user selects an item different from the previously selected one, a WebItemEvent is sent to all WebItemListeners added to the WebSelect.

WebSelect encapsulates the HTML <select> tag.

Example

Below fou find an example of how to use a WebSelect. You can try this example online: http://www.innoopract.com/w4content/

Properties of the WebSelect Component can be easily set in the Property-Editor of the W4T Eclipse Perspective. This example shows how to add or remove items from the WebSelect or change its appearence within the programm flow. The code is located in the in the event handler section and executed when buttons, checkboxes or dropdowns are clicked.

The example WebSelect is named wslExample.

  private void doWbtAddControlWebActionPerformed( WebEvent e ) throws Exception {
    String newItem = wtxAddControl.getValue();
    wslExample.addItem( newItem );
  }
  
  private void doWslSizeControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    String wslValue = wsl.getValue();
    int size = Integer.parseInt( wslValue.trim() );
    wslExample.setSize( size );
  }
  
  private void doWslExampleWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    String value = wsl.getValue();
    if( value.equals( "" ) ) {
      value = "[empty item]";
    }
    wlbValueDisplayControl.setValue( value );
  }
  
  private void doWbtRemoveControlWebActionPerformed( WebEvent e ) throws Exception {
    String currentItem = wslExample.getValue();
    wslExample.removeItem( currentItem );
  }
  
  private void doWcbEmptyItemControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebCheckBox wcb = ( WebCheckBox )e.getSource();
    wslExample.setUseEmptyItem( wcb.isSelected() );
  }
  

API documentation

The API documentation for WebSelect can be found here.