Class DefaultRadioButtonHandler
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.components.AbstractCompositeComponentHandler<T,Boolean>
-
- net.sf.jguiraffe.gui.builder.components.model.AbstractRadioButtonHandler<Integer>
-
- net.sf.jguiraffe.gui.builder.components.model.DefaultRadioButtonHandler
-
- All Implemented Interfaces:
CompositeComponentHandler<Integer,Boolean>,ComponentHandler<Integer>
public class DefaultRadioButtonHandler extends AbstractRadioButtonHandler<Integer>
A concrete default implementation of a
CompositeComponentHandlerfor a group of radio buttons.An instance of this class is used as
ComponentHandlerfor a radio button group if no specific handler class is specified. This implementation just uses the index of the selected button in the group as data. So a Java bean acting as model for a form that contains a radio button group should have a corresponding property of typeIntegerfor this group. Note that reallyIntegershould be used instead ofintbecause the value can be set to null if no radio button in the group is selected.Implementation note: This class is not thread-safe.
- Version:
- $Id: DefaultRadioButtonHandler.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description DefaultRadioButtonHandler()Creates a new instance ofDefaultRadioButtonHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intgetButtonIndex(Integer value)Returns the index of the radio button in the associated group that represents the passed in data value.protected IntegergetDataForButton(int idx)Returns the data value that corresponds to the radio button with the given index.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.model.AbstractRadioButtonHandler
getData, getUnselectedData, getUnselectedIndex, setData
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.AbstractCompositeComponentHandler
addHandler, getChildHandler, getChildHandlerCount, getChildHandlerIndex, getChildHandlerNameAt, getChildHandlerNames, getChildHandlers, getComponent, getOuterComponent, getType, isEnabled, setEnabled
-
-
-
-
Method Detail
-
getButtonIndex
protected int getButtonIndex(Integer value)
Returns the index of the radio button in the associated group that represents the passed in data value. Because the data value is interpreted as the selected index it is simply returned.- Specified by:
getButtonIndexin classAbstractRadioButtonHandler<Integer>- Parameters:
value- the data value- Returns:
- the index of the corresponding radio button
-
getDataForButton
protected Integer getDataForButton(int idx)
Returns the data value that corresponds to the radio button with the given index. Again because there is a 1:1 mapping between radio button index and data value the index can be directly returned as value.- Specified by:
getDataForButtonin classAbstractRadioButtonHandler<Integer>- Parameters:
idx- the index of the selected radio button- Returns:
- the corresponding data value
-
-