com.vaadin.ui.
Class RadioButtonGroup<T>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractListing<T>
-
- com.vaadin.ui.AbstractSingleSelect<T>
-
- com.vaadin.ui.RadioButtonGroup<T>
-
Type Parameters:
T
- item typeAll Implemented Interfaces:
HasDataProvider<T>
,HasItems<T>
,HasValue<T>
,ContextClickEvent.ContextClickNotifier
,FieldEvents.BlurNotifier
,FieldEvents.FocusNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,Component.Focusable
,SingleSelect<T>
,Serializable
public class RadioButtonGroup<T> extends AbstractSingleSelect<T> implements FieldEvents.FocusNotifier, FieldEvents.BlurNotifier, HasDataProvider<T>
A group of RadioButtons. Individual radiobuttons are made from items supplied by a
DataProvider
. RadioButtons may have captions and icons.Since:
8.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractListing
AbstractListing.AbstractListingExtension<T>
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description RadioButtonGroup()
Constructs a new RadioButtonGroup.
RadioButtonGroup(String caption)
Constructs a new RadioButtonGroup with caption.
RadioButtonGroup(String caption, DataProvider<T,?> dataProvider)
Constructs a new RadioButtonGroup with caption and DataProvider.
RadioButtonGroup(String caption, Collection<T> items)
Constructs a new RadioButtonGroup with caption and DataProvider containing given items.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Registration
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.DataProvider<T,?>
getDataProvider()
Returns the source of data items used by this listing.
ItemCaptionGenerator<T>
getItemCaptionGenerator()
Gets the item caption generator that is used to produce the strings shown in the combo box for each item.
DescriptionGenerator<T>
getItemDescriptionGenerator()
Gets the item description generator.
SerializablePredicate<T>
getItemEnabledProvider()
Returns the item enabled predicate.
IconGenerator<T>
getItemIconGenerator()
Gets the currently used item icon generator.
protected RadioButtonGroupState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected RadioButtonGroupState
getState(boolean markAsDirty)
Returns the shared state for this connector.
boolean
isHtmlContentAllowed()
Checks whether captions are interpreted as html or plain text.
protected T
readItem(org.jsoup.nodes.Element child, Set<T> selected, DesignContext context)
Reads an Item from a design and inserts it into the data source.
protected void
readItems(org.jsoup.nodes.Element design, DesignContext context)
Reads the data source items from the
design
.void
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
void
setHtmlContentAllowed(boolean htmlContentAllowed)
Sets whether html is allowed in the item captions.
void
setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
Sets the item caption generator that is used to produce the strings shown in the combo box for each item.
void
setItemDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
Sets the description generator that is used for generating descriptions for items.
void
setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
Sets the item enabled predicate for this radiobutton group.
void
setItemIconGenerator(IconGenerator<T> itemIconGenerator)
Sets the item icon generator that is used to produce custom icons for shown items.
protected org.jsoup.nodes.Element
writeItem(org.jsoup.nodes.Element design, T item, DesignContext context)
Writes a data source Item to a design.
-
Methods inherited from class com.vaadin.ui.AbstractSingleSelect
addSelectionListener, addValueChangeListener, getCustomAttributes, getSelectedItem, getValue, isReadOnly, isRequiredIndicatorVisible, isSelected, keyToItem, setReadOnly, setRequiredIndicatorVisible, setSelectedItem, setSelectedItem, setValue, updateSelectedItemState
-
Methods inherited from class com.vaadin.ui.AbstractListing
addDataGenerator, deserializeDeclarativeRepresentation, doReadDesign, doWriteDesign, focus, getDataCommunicator, getTabIndex, internalGetDataProvider, internalSetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setTabIndex, writeDesign, writeItems
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.HasDataProvider
setItems
-
Methods inherited from interface com.vaadin.data.HasValue
clear, getDefaultValidator, getEmptyValue, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Constructor Detail
-
RadioButtonGroup
public RadioButtonGroup(String caption)
Constructs a new RadioButtonGroup with caption.
Parameters:
caption
- caption text
-
RadioButtonGroup
public RadioButtonGroup(String caption, DataProvider<T,?> dataProvider)
Constructs a new RadioButtonGroup with caption and DataProvider.
Parameters:
caption
- the caption textdataProvider
- the data provider, not nullSee Also:
-
RadioButtonGroup
public RadioButtonGroup(String caption, Collection<T> items)
Constructs a new RadioButtonGroup with caption and DataProvider containing given items.
Parameters:
caption
- the caption textitems
- the data items to use, not nullSee Also:
-
RadioButtonGroup
public RadioButtonGroup()
Constructs a new RadioButtonGroup.
-
-
Method Detail
-
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed)
Sets whether html is allowed in the item captions. If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.
Parameters:
htmlContentAllowed
- true if the captions are used as html, false if used as plain text
-
isHtmlContentAllowed
public boolean isHtmlContentAllowed()
Checks whether captions are interpreted as html or plain text.
Returns:
true if the captions are used as html, false if used as plain text
See Also:
-
getState
protected RadioButtonGroupState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
Overrides:
getState
in classAbstractSingleSelect<T>
Returns:
updated component shared state
-
getState
protected RadioButtonGroupState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractSingleSelect<T>
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
getItemIconGenerator
public IconGenerator<T> getItemIconGenerator()
Description copied from class:
AbstractListing
Gets the currently used item icon generator. The default item icon provider returns null for all items, resulting in no icons being used.
Implementations that support item icons make this method public.
Overrides:
getItemIconGenerator
in classAbstractListing<T>
Returns:
the currently used item icon generator, not null
See Also:
IconGenerator
,AbstractListing.setItemIconGenerator(IconGenerator)
-
setItemIconGenerator
public void setItemIconGenerator(IconGenerator<T> itemIconGenerator)
Description copied from class:
AbstractListing
Sets the item icon generator that is used to produce custom icons for shown items. The generator can return null for items with no icon.
Implementations that support item icons make this method public.
Overrides:
setItemIconGenerator
in classAbstractListing<T>
Parameters:
itemIconGenerator
- the item icon generator to set, not nullSee Also:
-
getItemCaptionGenerator
public ItemCaptionGenerator<T> getItemCaptionGenerator()
Description copied from class:
AbstractListing
Gets the item caption generator that is used to produce the strings shown in the combo box for each item.
Overrides:
getItemCaptionGenerator
in classAbstractListing<T>
Returns:
the item caption generator used, not null
-
setItemCaptionGenerator
public void setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
Description copied from class:
AbstractListing
Sets the item caption generator that is used to produce the strings shown in the combo box for each item. By default,
String.valueOf(Object)
is used.Overrides:
setItemCaptionGenerator
in classAbstractListing<T>
Parameters:
itemCaptionGenerator
- the item caption provider to use, not null
-
getItemEnabledProvider
public SerializablePredicate<T> getItemEnabledProvider()
Returns the item enabled predicate.
Returns:
the item enabled predicate
See Also:
setItemEnabledProvider(com.vaadin.server.SerializablePredicate<T>)
-
setItemEnabledProvider
public void setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
Sets the item enabled predicate for this radiobutton group. The predicate is applied to each item to determine whether the item should be enabled (true) or disabled (false). Disabled items are displayed as grayed out and the user cannot select them. The default predicate always returns true (all the items are enabled).
Parameters:
itemEnabledProvider
- the item enable predicate, not null
-
setItemDescriptionGenerator
public void setItemDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
Sets the description generator that is used for generating descriptions for items. Description is shown as a tooltip when hovering on corresponding element. If the generator returns
null
, no tooltip is shown.Parameters:
descriptionGenerator
- the item description generator to set, notnull
Since:
8.2
-
getItemDescriptionGenerator
public DescriptionGenerator<T> getItemDescriptionGenerator()
Gets the item description generator.
Returns:
the item description generator
Since:
8.2
-
addFocusListener
public Registration addFocusListener(FieldEvents.FocusListener listener)
Description copied from interface:
FieldEvents.FocusNotifier
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.Specified by:
addFocusListener
in interfaceFieldEvents.FocusNotifier
Parameters:
listener
- the focus listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
addBlurListener
public Registration addBlurListener(FieldEvents.BlurListener listener)
Description copied from interface:
FieldEvents.BlurNotifier
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Specified by:
addBlurListener
in interfaceFieldEvents.BlurNotifier
Parameters:
listener
- the blur listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
readItems
protected void readItems(org.jsoup.nodes.Element design, DesignContext context)
Description copied from class:
AbstractListing
Reads the data source items from the
design
.Overrides:
readItems
in classAbstractSingleSelect<T>
Parameters:
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the design
-
readItem
protected T readItem(org.jsoup.nodes.Element child, Set<T> selected, DesignContext context)
Description copied from class:
AbstractSingleSelect
Reads an Item from a design and inserts it into the data source. Hierarchical select components should override this method to recursively recursively read any child items as well.
Overrides:
readItem
in classAbstractSingleSelect<T>
Parameters:
child
- a child element representing the itemselected
- A set accumulating selected items. If the item that is read is marked as selected, its item id should be added to this set.context
- the DesignContext instance used in parsingReturns:
the item id of the new item
-
writeItem
protected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design, T item, DesignContext context)
Description copied from class:
AbstractListing
Writes a data source Item to a design. Hierarchical select components should override this method to recursively write any child items as well.
Overrides:
writeItem
in classAbstractSingleSelect<T>
Parameters:
design
- the element into which to insert the itemitem
- the item to writecontext
- the DesignContext instance used in writingReturns:
a JSOUP element representing the
item
-
getDataProvider
public DataProvider<T,?> getDataProvider()
Description copied from interface:
HasItems
Returns the source of data items used by this listing.
Specified by:
getDataProvider
in interfaceHasItems<T>
Returns:
the data provider, not null
-
setDataProvider
public void setDataProvider(DataProvider<T,?> dataProvider)
Description copied from interface:
HasDataProvider
Sets the data provider for this listing. The data provider is queried for displayed items as needed.
Specified by:
setDataProvider
in interfaceHasDataProvider<T>
Parameters:
dataProvider
- the data provider, not null
-
-