Class Radio
- java.lang.Object
-
- org.openidentityplatform.openam.click.control.AbstractControl
-
- org.openidentityplatform.openam.click.control.Field
-
- org.openidentityplatform.openam.click.control.Radio
-
- All Implemented Interfaces:
Serializable,org.apache.click.Stateful,org.openidentityplatform.openam.click.Control
public class Radio extends Field
Provides a Radio control: <input type='radio'>.
The Radio control is generally used within a RadioGroup, for an code example please see theExample <input type='radio' name='header' value='Radio Control'>Radio</input> RadioGroupJavadoc example. When used with a RadioGroup the Radio control will derive its name from the parent RadioGroup, if the Radio's name is not defined.See also W3C HTML reference INPUT
- See Also:
RadioGroup, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancheckedThe field checked value.-
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 Radio()Create an Radio field with no name defined.Radio(String value)Create a radio field with the given value.Radio(String value, String label)Create a radio field with the given value and label.Radio(String value, String label, String name)Create a radio field with the given value, label and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbindRequestValue()Bind the request submission, setting the Fieldcheckedproperty if defined in the request.StringgetId()Return the Radio field id attribute.StringgetLabel()Return the field display label.StringgetName()Return the name of the Radio field.StringgetTag()Return the radio's html tag:input.StringgetType()Return the input type: 'radio'.booleanisChecked()Return true if the radio is checked, or false otherwise.booleanonProcess()Process the request Context setting the checked value if selected and invoking the controls listener if defined.voidrender(HtmlStringBuffer buffer)Render a HTML Radio string.voidsetChecked(boolean value)Set the selected value of the radio.voidsetParent(Object parent)Set the parent of the Field.voidsetValue(String value)Set the radio value, setting the checked status if given value is the same as the radio field value.-
Methods inherited from class org.openidentityplatform.openam.click.control.Field
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getValidationJavaScript, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValueObject, setWidth, validate
-
Methods inherited from class org.openidentityplatform.openam.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getControlSizeEst, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onDestroy, onInit, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString
-
-
-
-
Constructor Detail
-
Radio
public Radio(String value)
Create a radio field with the given value.- Parameters:
value- the label of the field
-
Radio
public Radio(String value, String label)
Create a radio field with the given value and label.- Parameters:
value- the label of the fieldlabel- the name of the field
-
Radio
public Radio(String value, String label, String name)
Create a radio field with the given value, label and name.- Parameters:
value- the label of the fieldlabel- the label of the fieldname- the name of the field
-
Radio
public Radio()
Create an Radio field with no name defined.
-
-
Method Detail
-
getTag
public String getTag()
Return the radio's html tag:input.- Overrides:
getTagin classAbstractControl- Returns:
- this controls html tag
- See Also:
AbstractControl.getTag()
-
isChecked
public boolean isChecked()
Return true if the radio is checked, or false otherwise.- Returns:
- true if the radio is checked.
-
setChecked
public void setChecked(boolean value)
Set the selected value of the radio.- Parameters:
value- the selected value
-
getId
public String getId()
Return the Radio field id attribute.
-
setParent
public void setParent(Object parent)
Set the parent of the Field.- Specified by:
setParentin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
setParentin classField- Parameters:
parent- the parent of the Control- Throws:
IllegalArgumentException- if the given parent instance is referencingthisobject:if (parent == this)- See Also:
Control.setParent(Object)
-
getLabel
public String getLabel()
Return the field display label.If the label value is null, this method will attempt to find a localized label message in the parent messages using the key:
If the Radio name attribute is not null:
If the Radio name attribute is null and the parent of the Radio is the RadioGroup:super.getName() + ".label"
If not found then the message will be looked up in theparent.getName() + "." + getValue() + ".label"/click-control.propertiesfile using the same key. If a value still cannot be found then the Field name will be the radio value.For example given a
CustomerPagewith the properties fileCustomerPage.properties:gender.M.label=Male gender.F.label=Female
The page Radio code:public class CustomerPage extends Page { public Form form = new Form(); private RadioGroup radioGroup = new RadioGroup("gender"); public CustomerPage() { radioGroup.add(new Radio("M")); radioGroup.add(new Radio("F")); form.add(radioGroup); .. } }
Will render the Radio label properties as:<input type="radio" name="gender" value="M"><label>Male</label></label><br/> <input type="radio" name="gender" value="F"><label>Female</label></label>
-
getName
public String getName()
Return the name of the Radio field. If the Radio name attribute has not been explicitly set, this method will return its parent RadioGroup's name if defined.- Specified by:
getNamein interfaceorg.openidentityplatform.openam.click.Control- Overrides:
getNamein classAbstractControl- Returns:
- the name of the control
- See Also:
Control.getName()
-
getType
public String getType()
Return the input type: 'radio'.- Returns:
- the input type: 'radio'
-
setValue
public void setValue(String value)
Set the radio value, setting the checked status if given value is the same as the radio field value.- Overrides:
setValuein classField- Parameters:
value- the Field value- See Also:
Field.setValue(String)
-
bindRequestValue
public void bindRequestValue()
Bind the request submission, setting the Fieldcheckedproperty if defined in the request.- Overrides:
bindRequestValuein classField
-
onProcess
public boolean onProcess()
Process the request Context setting the checked value if selected and invoking the controls listener if defined.
-
render
public void render(HtmlStringBuffer buffer)
Render a HTML Radio string.- 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:
AbstractControl.toString()
-
-