Provides a container group for Radio components. The RadioGroup itself must be within a Form component. The Radio and RadioGroup components work together to update a property of an object, much like a more flexible version of a PropertySelection . This component should wrap around other Radio components.


RadioGroup components may not nest.

See also: org.apache.tapestry.form.RadioGroup , Option , PropertySelection , Radio , Select


Name Type Required Default Description
selected Object yes Read during rendering to determine which Radio will be the default. Updated during rewinding (when the form is submitted) to indicate which radio button was selected by the user (null if no button was selected).
disabled boolean no false If true, then all contained Radio components will be disabled as well.
displayName string no The user-presentable name for the component, which will be used by a FieldLabel connected to the component.
validators Array or collection of Validator no The validators to apply to the component. Something along the lines of: validators:required .

See also: Validation
translator Translator no The translator to use when displaying and parsing the date.

See also: Validation

Body: allowed

Informal parameters: forbidden

Reserved parameters: none


Simple Example

This RadioGroup example illustrates an order form where a user can select the order size.

<form jwcid="@Form" success="listener:doSubmit">
 <label jwcid="@FieldLabel" field="component:size">Radio</label>
 <span jwcid="size@RadioGroup" selected="ognl:orderSize" displayName="Size" validators="validators:required">
  <input type="radio" jwcid="@Radio" value="ognl:@com.myexample.OrderPage@SMALL"/> Small
  <input type="radio" jwcid="@Radio" value="ognl:@com.myexample.OrderPage@MEDIUM"/> Medium
  <input type="radio" jwcid="@Radio" value="ognl:@com.myexample.OrderPage@LARGE"/> Large
  <input type="submit" value="Order"/>
package com.myexample;

import org.apache.tapestry.html.BasePage;

public abstract class OrderPage extends BasePage {

  public final static Integer SMALL = new Integer(1);
  public final static Integer MEDIUM = new Integer(2);
  public final static Integer LARGE = new Integer(3);

  public abstract Integer getOrderSize();

  public void doSubmit() {
    // process order



Ajax Example

This example shows how to intercept user-actions on a RadioGroup asynchronously on the server. Note: This does only work since 4.1.6

This is accomplished by targeting the @EventListener-annotation at the RadioGroup-element's onChange( index ) method. This method will be called whenever the user clicks on of the group's radio-buttons. The index of the clicked button is passed as an argument, which is helpful if you choose not to submit the enclosing form automatically (autoSubmit=false).

<form jwcid="@Form" >
    <span  jwcid="choose@RadioGroup" selected="ognl:choice"
           displayName="Choose" validators="validators:required" >
        <input jwcid="@Radio" value="Yes" />&nbsp;Yes&nbsp;
        <input jwcid="@Radio" value="No" />&nbsp;No
        <input jwcid="@Radio" value="Perhaps" />&nbsp;Perhaps
<p jwcid="ajaxResponse@Any" style="background:yellow;">
   You've chosen
    <span jwcid="@Insert" value="ognl:choice==null ? 'nothing' : '\''+choice+'\''"/>
public abstract class AsyncForm extends BasePage
    public abstract String getChoice();

    @EventListener( targets = "choose", events = "onChange", autoSubmit=true )
    public void onRadioButtonPressed( BrowserEvent b )
        String msg = "You've chosen option " + b.getMethodArguments().get(0) +" -> " + getChoice();
        System.out.println( msg );