We need you!

Icon

The IzPack documentation needs work, and you are invited to edit it!

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Description

The radio buttons are useful when the user needs to select a specific option out of a pre-defined list of choices. This field offers an arbitrary number of mutually exclusive buttons, each with its own label. The placement of the buttons and labels is different form other fields. First, the button is placed to the left and the label text to the right. Second, the buttons are not lined up all the way to the left as other labels are but they are indented from that location. As with other fields, the description is placed above the list of radio buttons and uses the entire available layout width. To specify a set of radio buttons create a <field> tag and use the type attribute with a value of radio. The txt and `` id`` attributes are not supported here. As with all other input fields, the variable attribute specifies that variable that should be replaced with the user selection.

Data

The data consists of two items, a description and the spec. The <spec> tag has no attributes, instead the specification details are entered as data within the `` <spec>`` tag. The <spec> data consists of one or more <choice> tags. One <choice> tag is required for each radio button. The `` <choice>`` tag accepts the usual txt and id attributes, which are used to specify the label text. In addition the following attributes are supported:

value - required

The value attribute is used to specify which value to insert if this associated radio button is selected. In other words, the label text has nothing to do with the value that is actually substituted for the variable. For this reason there is never an issue if multiple languages are used, the value is always the same for a given selection.

set - optional

The set attribute accepts the values true and false. Since the attribute is optional it can also be omitted, which is interpreted as false. If a value oftrue is used, the associated radio button will be selected when the UI is first presented. Obviously, only one of the buttons in a set should be set to true.

Example

The following example creates a set of four radio buttons with description. The second button will be selected when the UI is first presented.

Code Block
titleExample
languagehtml/xml
<field type="radio" variable="radioSelection">
  <description align="left" txt="This is a description for radio buttons" id="description.radio"/>
  <spec>
    <choice txt="the first choice" id="radio.label.1" value="1 selected" />
    <choice txt="the second choice" id="radio.label.2" value="2 selected" set="true" />
    <choice txt="the third choice" id="radio.label.3" value="3 selected" />
    <choice txt="the fourth choice" id="radio.label.4" value="4 selected" />
  </spec>
</field>

Beginning from IzPack 5 you can also make single choice elements visible or unvisible depending on conditions:

Code Block
titleExample
languagehtml/xml
<field type="radio" variable="database.operation">
  <description align="left" txt="Database Operation" id="database.operation.panel.field.description"/>
  <spec>
    <choice txt="Update existing database (without admin permission)"
            id="database.operation.panel.radio.choice.upgrade.label"
            value="update"
            conditionid="database.operation.panel.radio.choice.upgrade.enabled"/>
    <choice txt="Structure creation only (without admin permission)"
            id="database.operation.panel.radio.choice.create_structure.label"
            value="create_structure"
            conditionid="database.operation.panel.radio.choice.create_structure.enabled"/>
    <choice txt="Instance and structure creation (requires admin permission)"
            id="database.operation.panel.radio.choice.create_instance_and_structure.label"
            value="create_instance_and_structure"
            conditionid="database.operation.panel.radio.choice.create_instance_and_structure.enabled"/>
    <choice txt="Configure database later"
            id="database.operation.panel.radio.choice.noop.label"
            value="noop"
            conditionid="database.operation.panel.radio.choice.noop.enabled"/>
  </spec>
</field>