Class RadioButtonGroup
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WBeanComponent
-
- com.github.bordertech.wcomponents.AbstractInput
-
- com.github.bordertech.wcomponents.RadioButtonGroup
-
- All Implemented Interfaces:
AjaxTrigger
,BeanAware
,BeanBound
,BeanProviderBound
,DataBound
,Diagnosable
,Disableable
,Input
,Labelable
,Mandatable
,MultiInputComponent
,SubordinateTrigger
,WComponent
,WebComponent
,Serializable
public class RadioButtonGroup extends AbstractInput implements AjaxTrigger, SubordinateTrigger, MultiInputComponent
This class is used to create a group of radio buttons.
A
WRadioButton
can only be created by using theaddRadioButton(Object)
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 component tree.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.- Since:
- 1.0.0
- Author:
- Jonathan Austin
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractInput
AbstractInput.InputModel
-
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
-
-
Constructor Summary
Constructors Constructor Description RadioButtonGroup()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WRadioButton
addRadioButton()
This method will add a radio button to the group.WRadioButton
addRadioButton(Object value)
This method will add a radio button to the group with the given value.protected boolean
doHandleRequest(Request request)
This method will only processes a request where the group is on the request and has no value.String
getRequestValue(Request request)
Provide the value of the component on the Request.String
getSelectedValue()
Retrieves the selected value for this group.String
getValue()
Provide the value of the component returned byDataBound.getData()
in the correct format.protected boolean
isPresent(Request request)
Determine if this component is on the Request.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
setFocussed()
The radio button group does not set focus.void
setSelectedValue(String value)
Sets the selected value for this group.void
setSubmitOnChange(boolean submitOnChange)
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.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractInput
addValidator, beforeHandleRequest, createMandatoryDiagnostic, doHandleChanged, getActionCommand, getActionObject, getActionOnChange, getComponentModel, getDefaultSubmitButton, getDiagnostics, getOrCreateComponentModel, getValidators, getValueAsString, handleRequest, isChangedInLastRequest, isCurrentAjaxTrigger, isDisabled, isEmpty, isMandatory, isReadOnly, newComponentModel, setActionObject, setActionOnChange, setChangedInLastRequest, setDefaultSubmitButton, setDisabled, setMandatory, setMandatory, setReadOnly, showErrorIndicatorsForComponent, showIndicatorsForComponent, showWarningIndicatorsForComponent, toString, validateComponent
-
Methods inherited from class com.github.bordertech.wcomponents.WBeanComponent
addBeanToScratchMap, doUpdateBeanValue, getBean, getBeanFromScratchMap, getBeanId, getBeanProperty, getBeanProvider, getBeanScratchMap, getBeanValue, getData, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, 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, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContext, tidyUpUIContextForTree, validate, 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.BeanAware
getBean, getBeanProperty, getBeanValue, setBeanProperty
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanBound
isSearchAncestors, setBean
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanProviderBound
getBeanId, setBeanId, setBeanProvider
-
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, handleRequest, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Method Detail
-
getValue
public String getValue()
Provide the value of the component returned byDataBound.getData()
in the correct format.If required, this method can convert the data into the correct type and also do any validation before the value is used.
- Specified by:
getValue
in interfaceInput
- Overrides:
getValue
in classAbstractInput
- Returns:
- the value of the component returned by
DataBound.getData()
in the correct format.
-
doHandleRequest
protected boolean doHandleRequest(Request request)
This method will only processes a request where the group is on the request and has no value. If the group has no value, then none of the group's radio buttons will be triggered to process the request.- Specified by:
doHandleRequest
in classAbstractInput
- Parameters:
request
- the request being responded to.- Returns:
- true if the group has changed, otherwise false
-
setFocussed
public void setFocussed()
The radio button group does not set focus. It allows the radio buttons to set their own focus if they are selected.- Specified by:
setFocussed
in interfaceWComponent
- Overrides:
setFocussed
in classAbstractWComponent
-
getRequestValue
public String getRequestValue(Request request)
Provide the value of the component on the Request.If the component is not on the request, the components current value will be provided.
- Specified by:
getRequestValue
in interfaceInput
- Parameters:
request
- the request being responded to.- Returns:
- the value of this component on the Request, or its current state if it is not on the request.
-
isPresent
protected boolean isPresent(Request request)
Determine if this component is on the Request.- Overrides:
isPresent
in classAbstractInput
- Parameters:
request
- the request being responded to.- Returns:
- true if this component is on the Request, otherwise return false.
-
getSelectedValue
public String getSelectedValue()
Retrieves the selected value for this group.- Returns:
- the value of the selected radio button, or null if there is no selection.
-
setSelectedValue
public void setSelectedValue(String value)
Sets the selected value for this group.- Parameters:
value
- the selected value, or null to clear the selection.
-
setSubmitOnChange
@Deprecated public void setSubmitOnChange(boolean submitOnChange)
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.Sets whether the form should be submitted when the selection changes.- Parameters:
submitOnChange
- true to submit the form on change.
-
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 the form should be submitted when the selection changes.- Returns:
- true if the form should be submitted on change.
-
addRadioButton
public WRadioButton addRadioButton(Object value)
This method will add a radio button to the group with the given value. The value must be unique for the group.The radio button returned by this method must be added to the required location in the UI Component tree.
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.- Parameters:
value
- a unique value for the radio button.- Returns:
- the radio button that was added to the group
-
addRadioButton
public WRadioButton addRadioButton()
This method will add a radio button to the group.Unlike {
addRadioButton(Object)
, which requires a value to be passed in, this method has no value passed in for the radio button, as it is expected the radio button will be used with aWRepeater
and will get its value from a bean. The bean property will default to ".", but can be set to the appropriate bean property after being returned.The radio button returned by this method must be added to the required location in the UI Component tree.
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.- Returns:
- the radio button that was added to the group
-
-