Class RadioGroupTag

  • All Implemented Interfaces:
    ConditionalTag, org.apache.commons.jelly.Tag

    public class RadioGroupTag
    extends FieldTag

    A tag for creating a radio group.

    When working with radio buttons it is not enough to insert these components into the generated GUI (by using the corresponding tags), but the groups the radio buttons belong to must also be defined. Without this information the special property of radio buttons - that only one button can be selected - could not be realized.

    Because the group a number of radio buttons belong to need not be correlated with the controls' layout, the form builder library treats radio groups as non visible, non GUI components. So they are not themselves added to the generated GUI; they are merely logic elements implementing the radio button functionality. However, they are added as field to the enclosing Form , and thus the data of the group can be queried.

    To define a radio group the same concept as is used for logic component groups is used: A RadioGroupTag internally creates a component group analogously to the ComponentGroupTag. Components can be added to this group by either nesting them inside the RadioGroupTag tag or by specifying the group's name in the groups attribute.

    The main difference between this tag and the ComponentGroupTag lies in the fact that this tag calls the component manager's createRadioGroup() method at the very end of the building process and ensures that all elements of the group are added to the radio group. It is then in the responsibility of the ComponentManager implementation to provide a suitable implementation of the radio group behavior (e.g. in Swing there is a corresponding non visual object implementing the desired functionality). Though it is a non visible component, the new radio group will be added to the component list of the central ComponentBuilderData instance.

    This tag is derived from FieldTag and therefore supports the typical attributes of input components. However, in this context only the name attribute makes sense which also determines the name of the component group created for the radio group. In the body of this tag a ComponentHandlerTag can be placed for specifying a custom ComponentHandler. Note that the ComponentHandler specified here must be derived from CompositeComponentHandler because the component handlers for the single radio buttons are added to it. If no ComponentHandler is specified, a default component handler for the radio button group is created: an instance of the DefaultRadioButtonHandler class.

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

      • RadioGroupTag

        public RadioGroupTag()
    • Method Detail

      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Performs processing before the tag's body is evaluated. This implementation sets a default ComponentHandler and creates the component group for managing the radio buttons.
        Overrides:
        processBeforeBody in class InputComponentTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is used incorrectly
        FormBuilderException - if an error occurs
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException,
                               FormBuilderException
        Executes this tag. After the processing of the base class this implementation creates and initializes a call back object that will create the radio group at the very end of the building process.
        Overrides:
        process in class InputComponentTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is used incorrectly
        FormBuilderException - if an error occurs