Jump to: navigation, search

Scout/Concepts/RadioButtonGroup

< Scout‎ | Concepts
Revision as of 02:33, 15 April 2013 by Jbr.bsiag.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Scout
Wiki Home
Website
DownloadGit
Community
ForumsBlogTwitter
Bugzilla
Bugzilla


Specific type of value field to propose a choice between a limited number of possibilities.

  • implements: I obj.pngIRadioButtonGroup<T>
  • extends: C obj.pngAbstractRadioButtonGroup<T>

Description

The RadioButtonGroup can be used to show a CodeType or a LookupCall as RadioButtons. A RadioButtonGroup is a normal value field with parameterized type <T>.

Only one of the RadioButtons can be selected.

Another possibility is to define the radio Button as Inner-Class: RadioButton. In this case, the value of the field is defined in each RadioButton with the RadioValue property.


A RadioButtonGroup can also contain some other fields in the group (as inner class).

Note.png
TODO
Merge from forum: "list" of sections where a radio button is on the left and a group box or other field is on the right


Example

Here is some code to propose to choose between three colors (red, green and blue):

public class ColorGroup extends AbstractRadioButtonGroup<String> {
 
  @Override
  protected String getConfiguredLabel() {
    return TEXTS.get("Color");
  }
 
  @Order(10.0)
  public class RedButton extends AbstractRadioButton {
 
    @Override
    protected String getConfiguredLabel() {
      return TEXTS.get("Red");
    }
 
    @Override
    protected Object getConfiguredRadioValue() {
      return "RED";
    }
  }
 
  @Order(20.0)
  public class GreenButton extends AbstractRadioButton {
 
    @Override
    protected String getConfiguredLabel() {
      return TEXTS.get("Green");
    }
 
    @Override
    protected Object getConfiguredRadioValue() {
      return "GREEN";
    }
  }
 
  @Order(30.0)
  public class BlueButton extends AbstractRadioButton {
 
    @Override
    protected String getConfiguredLabel() {
      return TEXTS.get("Blue");
    }
 
    @Override
    protected Object getConfiguredRadioValue() {
      return "BLUE";
    }
  }
}

Corresponding screenshot: Scout Color RadioGroup.png

The value can be set directly:

getColorGroup().setValue("RED");

where getColorGroup() is the convienece function add by the Scout SDK to get the ColorGroup field:

public ColorGroup getColorGroup() {
  return getFieldByClass(ColorGroup.class);
}

Of course, as for any other value field, it is possible to use the formData:

formData.getColorGroup().setValue("BLUE");


Another possibility to create the radio button is to use a code type. Here we use YesOrNoCodeType:

public class YesOrNoGroup extends AbstractRadioButtonGroup<Boolean> {
 
  @Override
  protected String getConfiguredLabel() {
    return TEXTS.get("YesOrNo");
  }
 
  @Override
  protected Class<? extends ICodeType> getConfiguredCodeType() {
    return YesOrNoCodeType.class;
  }
}

The <T> of AbstractRadioButtonGroup needs to match the Id returned by the Code.

The value can also be set directly or with the formData:

getFieldByClass(YesOrNoGroup.class).setValue(Boolean.FALSE)
formData.getYesOrNoGroup().setValue(Boolean.TRUE);

Screenshot

RAP SWT Swing Swing Rayo
Scout 3.8 RadioButtonGroup RAP.png Scout 3.8 RadioButtonGroup SWT.png Scout 3.8 RadioButtonGroup Swing.png Scout 3.8 RadioButtonGroup Swing Rayo.png

Properties

Defined with getConfiguredXxxxxx() methods.

See also the Field and the Value field pages for the properties that all fields have in common.


Events

Defined with execXxxxxx() methods.

See also the Field and the Value field pages for the events that all fields have in common.


See Also