Class RadioGroup
- java.lang.Object
-
- org.openidentityplatform.openam.click.control.AbstractControl
-
- org.openidentityplatform.openam.click.control.Field
-
- org.openidentityplatform.openam.click.control.RadioGroup
-
- All Implemented Interfaces:
Serializable,org.apache.click.Stateful,org.openidentityplatform.openam.click.Control
public class RadioGroup extends Field
Provides a RadioGroup control.
The RadioGroup control provides a Field for containing grouped Radio buttons. Radio controls added to a RadioGroup will have their name set to that of the RadioGroup. This will ensure the buttons will toggle together so that only one button is selected at a time.Example Radio Group <input type='radio' name='header' value='R'>Red </input> <input type='radio' name='header' checked value='G'>Green </input> <input type='radio' name='header' value='B'>Blue</input> RadioGroup Example
The example below illustrates a RadioGroup being added to a form.public class Purchase extends Page { public Form form = new Form(); private RadioGroup radioGroup = new RadioGroup("packaging"); public Purchase() { radioGroup.add(new Radio("STD", "Standard ")); radioGroup.add(new Radio("PRO", "Protective ")); radioGroup.add(new Radio("GFT", "Gift Wrap ")); radioGroup.setValue("STD"); radioGroup.setVerticalLayout(true); form.add(radioGroup); .. } }
This radio group field would be render as:
See also W3C HTML reference INPUTExample Packaging <input type='radio' name='group' checked value='STD'>Standard</input>
<input type='radio' name='group' value='PRO'>Protective</input>
<input type='radio' name='group' value='GFT'>Gift Wrap</input>- See Also:
Radio, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisVerticalLayoutThe layout is vertical flag (default false).protected List<Radio>radioListThe list of Radio controls.protected static StringVALIDATE_RADIOGROUP_FUNCTIONThe field validation JavaScript function template.-
Fields inherited from class org.openidentityplatform.openam.click.control.Field
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value
-
Fields inherited from class org.openidentityplatform.openam.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
-
-
Constructor Summary
Constructors Constructor Description RadioGroup()Create a RadioGroup field with no name.RadioGroup(String name)Create a RadioGroup with the given name.RadioGroup(String name, boolean required)Create a RadioGroup with the given name and required status.RadioGroup(String name, String label)Create a RadioGroup with the given name and label.RadioGroup(String name, String label, boolean required)Create a RadioGroup with the given name, label and required status.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Radio radio)Add the given radio to the radio group.voidaddAll(Collection<?> objects, String value, String label)Add the given collection of objects to the RadioGroup, creating new Radio instances based on the object properties specified by value and label.voidaddAll(Collection<Radio> options)Add the given collection Radio item options to the RadioGroup.voidaddAll(Map<?,?> options)Add the given Map of radio values and labels to the RadioGroup.intgetControlSizeEst()Return the estimated rendered control size in characters.StringgetFocusJavaScript()Return the RadioGroup focus JavaScript.List<Radio>getRadioList()Return the list of radio controls.StringgetValidationJavaScript()Return the RadioGroup JavaScript client side validation function.booleanhasRadios()Return true if RadioGroup has Radio controls, or false otherwise.booleanisVerticalLayout()Return true if the radio control layout is vertical.voidonDestroy()This method does nothing.voidonInit()This method does nothing.booleanonProcess()Process the request Context setting the checked value and invoking the controls listener if defined.voidrender(HtmlStringBuffer buffer)Render the HTML representation of the RadioGroup.voidsetForm(Form form)Set the Field's the parentForm.voidsetVerticalLayout(boolean vertical)Set the vertical radio control layout flag.StringtoString()Return the HTML rendered RadioGroup string.voidvalidate()Validate the RadioGroup request submission.-
Methods inherited from class org.openidentityplatform.openam.click.control.Field
bindRequestValue, getError, getErrorLabel, getFocus, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setValueObject, setWidth
-
Methods inherited from class org.openidentityplatform.openam.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle
-
-
-
-
Field Detail
-
VALIDATE_RADIOGROUP_FUNCTION
protected static final String VALIDATE_RADIOGROUP_FUNCTION
The field validation JavaScript function template. The function template arguments are:- 0 - is the field id
- 1 - is the name of the radio button
- 2 - is the id of the form
- 3 - is the Field required status
- 4 - is the localized error message
- 5 - is the first radio id to select
- See Also:
- Constant Field Values
-
isVerticalLayout
protected boolean isVerticalLayout
The layout is vertical flag (default false). If the layout is vertical each Radio controls is rendered on a new line using the <br> tag.
-
-
Constructor Detail
-
RadioGroup
public RadioGroup(String name)
Create a RadioGroup with the given name.- Parameters:
name- the name of the field
-
RadioGroup
public RadioGroup(String name, boolean required)
Create a RadioGroup with the given name and required status.- Parameters:
name- the name of the fieldrequired- the field required status
-
RadioGroup
public RadioGroup(String name, String label)
Create a RadioGroup with the given name and label.- Parameters:
name- the name of the fieldlabel- the label of the field
-
RadioGroup
public RadioGroup(String name, String label, boolean required)
Create a RadioGroup with the given name, label and required status.- Parameters:
name- the name of the fieldlabel- the label of the fieldrequired- the field required status
-
RadioGroup
public RadioGroup()
Create a RadioGroup field with no name.Please note the control's name must be defined before it is valid.
-
-
Method Detail
-
add
public void add(Radio radio)
Add the given radio to the radio group. When the radio is added to the group it will use its parent RadioGroup's name when rendering if it has not already been set.- Parameters:
radio- the radio control to add to the radio group- Throws:
IllegalArgumentException- if the radio parameter is null
-
addAll
public void addAll(Collection<Radio> options)
Add the given collection Radio item options to the RadioGroup.- Parameters:
options- the collection of Radio items to add- Throws:
IllegalArgumentException- if options is null
-
addAll
public void addAll(Map<?,?> options)
Add the given Map of radio values and labels to the RadioGroup. The Map entry key will be used as the radio value and the Map entry value will be used as the radio label.It is recommended that
LinkedHashMapis used as the Map parameter to maintain the order of the radio items.- Parameters:
options- the Map of radio option values and labels to add- Throws:
IllegalArgumentException- if options is null
-
addAll
public void addAll(Collection<?> objects, String value, String label)
Add the given collection of objects to the RadioGroup, creating new Radio instances based on the object properties specified by value and label.RadioGroup radioGroup = new RadioGroup("type", "Type:"); radioGroup.addAll(getCustomerService().getCustomerTypes(), "id", "name"); form.add(select);
- Parameters:
objects- the collection of objects to render as radio optionsvalue- the name of the object property to render as the Radio valuelabel- the name of the object property to render as the Radio label- Throws:
IllegalArgumentException- if options, value or label parameter is null
-
getFocusJavaScript
public String getFocusJavaScript()
Return the RadioGroup focus JavaScript.- Overrides:
getFocusJavaScriptin classField- Returns:
- the RadioGroup focus JavaScript
-
setForm
public void setForm(Form form)
Description copied from class:FieldSet the Field's the parentForm.- Overrides:
setFormin classField- Parameters:
form- Field's parentForm- See Also:
Field.setForm(Form)
-
isVerticalLayout
public boolean isVerticalLayout()
Return true if the radio control layout is vertical.- Returns:
- true if the radio control layout is vertical
-
setVerticalLayout
public void setVerticalLayout(boolean vertical)
Set the vertical radio control layout flag.- Parameters:
vertical- the vertical layout flag
-
getRadioList
public List<Radio> getRadioList()
Return the list of radio controls.- Returns:
- the list of radio controls
-
hasRadios
public boolean hasRadios()
Return true if RadioGroup has Radio controls, or false otherwise.- Returns:
- true if RadioGroup has Radio controls, or false otherwise
-
getValidationJavaScript
public String getValidationJavaScript()
Return the RadioGroup JavaScript client side validation function.- Overrides:
getValidationJavaScriptin classField- Returns:
- the field JavaScript client side validation function
-
onInit
public void onInit()
Description copied from class:AbstractControlThis method does nothing. Subclasses may override this method to perform initialization.- Specified by:
onInitin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
onInitin classAbstractControl- See Also:
Control.onInit()
-
onProcess
public boolean onProcess()
Process the request Context setting the checked value and invoking the controls listener if defined.
-
onDestroy
public void onDestroy()
Description copied from class:AbstractControlThis method does nothing. Subclasses may override this method to perform clean up any resources.- Specified by:
onDestroyin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
onDestroyin classAbstractControl- See Also:
Control.onDestroy()
-
getControlSizeEst
public int getControlSizeEst()
Description copied from class:AbstractControlReturn the estimated rendered control size in characters.- Overrides:
getControlSizeEstin classAbstractControl- Returns:
- the estimated rendered control size in characters
- See Also:
AbstractControl.getControlSizeEst()
-
render
public void render(HtmlStringBuffer buffer)
Render the HTML representation of the RadioGroup.- Specified by:
renderin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
renderin classAbstractControl- Parameters:
buffer- the specified buffer to render the control's output to- See Also:
toString()
-
toString
public String toString()
Return the HTML rendered RadioGroup string.- Overrides:
toStringin classAbstractControl- Returns:
- the HTML rendered RadioGroup string
- See Also:
Object.toString()
-
validate
public void validate()
Validate the RadioGroup request submission.A field error message is displayed if a validation error occurs. These messages are defined in the resource bundle:
org.apache.click.control.MessageProperties
Error message bundle key names include:
- select-error
-
-