Class WRadioButton
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WBeanComponent
-
- com.github.bordertech.wcomponents.WRadioButton
-
- All Implemented Interfaces:
AjaxTarget
,BeanAware
,BeanBound
,BeanProviderBound
,DataBound
,Disableable
,Labelable
,SubordinateTarget
,WComponent
,WebComponent
,Serializable
public class WRadioButton extends WBeanComponent implements AjaxTarget, SubordinateTarget, Disableable, Labelable
A WRadioButton is a wcomponent used to display a radio button and must be used with a
RadioButtonGroup
.A WRadioButton instance can only be created by using the
addRadioButton(value)
method oraddRadioButton()
method. Call one of these methods to get an instance of a radio button and then add the radio button to the required location in the UI. Each radio button added to a group must have a unique value for that group.If the value of the radio button is known when creating its instance, then use the
addRadioButton(Object)
.If a radio button needs to be used in a repeating component and will have different values depending on its context, then use the
addRadioButton()
. Radio buttons used with aWRepeater
will get their value from the "bean" associated to the row in the repeater. By default, the bean property for the radio button will be set to ".", but this can be overridden by callingWBeanComponent.setBeanProperty(String)
on the radio button instance.For the radio button group to work correctly, it is important that each radio button in the group has a unique value. The radio button group uses the
String
representation of the radio button's value to identify which button has been selected. As the string representation of the radio button's value is sent to the client, be mindful that it should not be too large.To determine if a WRadioButton has been selected use the
isSelected
method. Alternatively, you can call thegetSelectedValue
method on theRadioButtonGroup
which will return the value associated with the WRadioButton which is currently selected.- Since:
- 1.0.0
- Author:
- James Gifford, Jonathan Austin
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RadioButtonGroup
getGroup()
Retrieves the RadioButtonGroup associated with this radio button.String
getGroupName()
Retrieves the name of the RadioButtonGroup that this button is associated with.String
getValue()
Retrieves the radio button's value.void
handleRequest(Request request)
This method will only process the request if the value for the group matches the button's value.boolean
isDisabled()
Indicates whether the radio button is disabled.boolean
isMandatory()
Indicates whether or not the radio button group is mandatory for a specific user.boolean
isReadOnly()
Indicates whether the radio button is read only in the given context.boolean
isSelected()
boolean
isSubmitOnChange()
Deprecated.1.4.0 as it results in a level A accessibility problem See https://www.w3.org/TR/UNDERSTANDING-WCAG20/consistent-behavior-unpredictable-change.html.void
setDisabled(boolean disabled)
Sets whether the radio button is disabled.void
setReadOnly(boolean readOnly)
Sets whether the radio button is read only.void
setSelected(boolean selected)
Sets whether the radio button is selected.-
Methods inherited from class com.github.bordertech.wcomponents.WBeanComponent
addBeanToScratchMap, doUpdateBeanValue, getBean, getBeanFromScratchMap, getBeanId, getBeanProperty, getBeanProvider, getBeanScratchMap, getBeanValue, getComponentModel, getData, getOrCreateComponentModel, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, newComponentModel, removeBeanFromScratchMap, resetData, setBean, setBeanId, setBeanProperty, setBeanProvider, setData, setSearchAncestors, updateBeanValue
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, toString, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Method Detail
-
handleRequest
public void handleRequest(Request request)
This method will only process the request if the value for the group matches the button's value.- Specified by:
handleRequest
in interfaceWComponent
- Overrides:
handleRequest
in classAbstractWComponent
- Parameters:
request
- the request being processed.
-
getGroupName
public String getGroupName()
Retrieves the name of the RadioButtonGroup that this button is associated with.- Returns:
- the group name, or null if not associated to a group.
-
isSelected
public boolean isSelected()
- Returns:
- true if the radio button is selected.
-
setSelected
public void setSelected(boolean selected)
Sets whether the radio button is selected.- Parameters:
selected
- true if the button should be selected, false if not
-
getValue
public String getValue()
Retrieves the radio button's value.The radio button group uses the
String
value of the radio button's value to identify which button has been selected. As the string representation of the radio button's value is sent to the client, be mindful that it should not be too large.- Returns:
- the radio button's value.
-
isMandatory
public boolean isMandatory()
Indicates whether or not the radio button group is mandatory for a specific user.- Returns:
- true if the radio button group is mandatory, false otherwise.
-
isSubmitOnChange
@Deprecated public boolean isSubmitOnChange()
Deprecated.1.4.0 as it results in a level A accessibility problem See https://www.w3.org/TR/UNDERSTANDING-WCAG20/consistent-behavior-unpredictable-change.html.Indicates whether selection of the radio button should trigger a form submit.- Returns:
- true if selection should trigger a submit.
-
getGroup
public RadioButtonGroup getGroup()
Retrieves the RadioButtonGroup associated with this radio button.- Returns:
- the associated RadioButtonGroup
-
isDisabled
public boolean isDisabled()
Indicates whether the radio button is disabled.- Specified by:
isDisabled
in interfaceDisableable
- Returns:
- true if the input is disabled, otherwise false.
-
setDisabled
public void setDisabled(boolean disabled)
Sets whether the radio button is disabled.- Specified by:
setDisabled
in interfaceDisableable
- Parameters:
disabled
- if true, the input is disabled. If false, it is enabled.
-
isReadOnly
public boolean isReadOnly()
Indicates whether the radio button is read only in the given context.- Returns:
- true if the input is read only, otherwise false.
-
setReadOnly
public void setReadOnly(boolean readOnly)
Sets whether the radio button is read only.- Parameters:
readOnly
- if true, the input is read only. If false, it is editable.
-
-