Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > UI Tag Reference > radio
Added by digi9ten, last edited by Ted Husted on Sep 02, 2006  (view change)
Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.
Important

Note that the listkey and listvalue attribute will default to "key" and "value" respectively only when the list attribute is evaluated to a Map or its decendant. Other thing else, will result in listkey and listvalue to be null and not used.

Description

Render a radio button input field.

Parameters

Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.

Examples

In this example, a radio control is displayed with a list of genders. The gender list is built from attribute id=genders. The framework calls getGenders() which will return a Map. For examples using listKey and listValue attributes, see the section select tag. The default selected one will be determined (in this case) by the getMale() method in the action class which should retun a value similar to the key of the getGenters() map if that particular gender is to be selected.

<s:action name="GenderMap" id="genders"/>
<s:radio label="Gender" name="male" list="#genders.genders"/>