WebRadioButton

General

A WebRadioButton is a s a graphical component which can be either in an "on" (checked) or "off" (unchecked) state. Clicking on a WebRadioButton changes its state from "on" to "off," or from "off" to "on."

A WebRadioButton must belong to a WebRadioButtonGroup, which may be specified. If no group is specified, a default group containing only this WebRadioButton is used. In every group at most one radio button can be checked.

The WebRadioButton appears unchecked by default. WebRadioButton and WebRadioButtonGroup encapsulate the HTML <input> element with type 'radio'.

Example

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

Properties of the WebRadioButton Component can be easily set in the Property-Editor of the W4T Eclipse Perspective. This example shows how to determine the selected value from a RadioButtonGroup or to disable the Group. The code is located in the in the event handler section and executed when buttons, checkboxes or dropdowns are clicked.

The example WebRadioButton is named wrbExample1.

  private void doWrbExample1WebItemStateChanged( WebEvent e ) throws Exception {
    WebRadioButtonGroup wrbGroup = wrbExample1.getGroup();
    String value = wrbGroup.getValue();
    WebRadioButton[] wrbs = wrbGroup.getWebRadioButtons();
    for( int i = 0; i < wrbs.length; i++ ) {
      if( wrbs[ i ].getValue().equals( value ) ) {
        wlbValueDisplayControl.setValue( wrbs[ i ].getLabel() );
      }
    }
  }  
  private void doWbtValueControlWebActionPerformed( WebEvent e ) throws Exception {
    String label = wslValueControl.getValue();
    WebRadioButtonGroup wrbGroup = wrbExample1.getGroup();
    WebRadioButton[] wrbs = wrbGroup.getWebRadioButtons();
    for( int i = 0; i < wrbs.length; i++ ) {
      if( wrbs[ i ].getLabel().equals( label ) ) {
        wrbs[ i ].getGroup().setValue( wrbs[ i ].getValue() );
      }
    }
    wlbValueDisplayControl.setValue( label );
  }
  private void doWcbEnabledControlWebItemStateChanged( WebEvent e ) throws Exception {
    boolean enabled = wcbEnabledControl.isSelected();
    WebRadioButtonGroup wrbGroup = wrbExample1.getGroup();
    wrbGroup.setEnabled( enabled );
  }
  

API documentation

The API documentation for WebRadioButton can be found here.