Class BooleanRadioButtonHandler

  • All Implemented Interfaces:
    CompositeComponentHandler<Boolean,​Boolean>, ComponentHandler<Boolean>

    public class BooleanRadioButtonHandler
    extends AbstractRadioButtonHandler<Boolean>

    A specialized ComponentHandler implementation for a radio button group with only two elements.

    This handler implementation is used for the radio button group which defines the sort direction. It can be either ascending or descending. For demonstration purposes we map these values to a boolean flag (true means descending, false means ascending). It would also be possible to use an enumeration type instead. This class mainly demonstrates how a custom component handler for radio buttons can be created.

    Version:
    $Id: BooleanRadioButtonHandler.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • BooleanRadioButtonHandler

        public BooleanRadioButtonHandler()
        Creates a new instance of BooleanRadioButtonHandler
    • Method Detail

      • getButtonIndex

        protected int getButtonIndex​(Boolean value)
        Returns the index of the button with the specified value. This method maps data values of the radio group to specific radio buttons. Because in our example true represents the descending button we return the corresponding index.
        Specified by:
        getButtonIndex in class AbstractRadioButtonHandler<Boolean>
        Parameters:
        value - the data value of the radio group
        Returns:
        the index of the selected radio button
      • getDataForButton

        protected Boolean getDataForButton​(int idx)
        Returns the value of the radio button with the specified index. This method determines the data value for the whole radio group based on the selected radio button. Here we return true if and only if the descending radio button is selected.
        Specified by:
        getDataForButton in class AbstractRadioButtonHandler<Boolean>
        Parameters:
        idx - the index of the selected radio button
        Returns:
        the corresponding value for the whole radio group