Class TabbedPaneTag

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

    public class TabbedPaneTag
    extends InputComponentTag
    implements Composite

    A specialized tag handler implementation for creating a tabbed pane.

    A tabbed pane provides an arbitrary number of registers, from which the user can select one. The content of this register is then displayed while all others are invisible.

    To fully define a tabbed pane in a builder script this tag is used together with the TabTag tag: For each register a <register> tag is to be placed in the body of this tag, in which the properties of the register are set. When the tag is processed the current ComponentManager implementation will construct proper tab components from this data.

    Though a tabbed pane itself usually does not contribute to the input data a user can enter in a form, these components are here treated as input components. The reason is that they have a state (the index of the selected register) that can be queried and altered by application code. This can be done through the ComponentHandler object that is created for the tabbed pane. This handler can also be used to register a change listener that will be notified when ever the selected tab register changes. However per default for a tabbed pane no form element will be created (i.e. the noField property is set to false).

    The following table lists the attributes that are supported by this tag. Note that some of the properties defined here may not be available in all underlying GUI libraries:

    Attribute Description Optional
    placement With this property the placement of the registers can be specified. It can have one of the values left, right, top, or bottom. The default value is top. Yes
    name Because tabbed panes are regular input components they can be given a name, under which they can be accessed. However the name is optional. If none is defined, a name of the following form is automatically generated: tabbedPane<n> with <n> being a serial number starting at 1. Yes

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

      • AUTO_NAME_PREFIX

        public static final String AUTO_NAME_PREFIX
        Constant for the prefix for automatically generated tab names.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TabbedPaneTag

        public TabbedPaneTag()
        Creates a new instance of TabbedPaneTag.
    • Method Detail

      • getPlacement

        public String getPlacement()
        Returns the string value of the placement attribute.
        Returns:
        the placement as string
      • setPlacement

        public void setPlacement​(String v)
        Set method of the placement attribute.
        Parameters:
        v - the attribute's value
      • getPlacementValue

        public TabbedPaneTag.Placement getPlacementValue()
        Returns the placement of this tabbed pane's registers.
        Returns:
        the placement of the registers
      • setPlacementValue

        public void setPlacementValue​(TabbedPaneTag.Placement p)
        Allows to directly specify a placement value. (This is used for testing mainly.)
        Parameters:
        p - the new placement value
      • addComponent

        public void addComponent​(Object comp,
                                 Object constraints)
        Adds a child component to this composite object. This implementation expects that the child component is a TabData object. Otherwise an exception is thrown. The constraints will be ignored.
        Specified by:
        addComponent in interface Composite
        Parameters:
        comp - the child component to be added
        constraints - the layout constraints object
        Throws:
        FormBuilderRuntimeException - if the passed in component is not a TabData object
      • getContainer

        public Object getContainer()
        Returns the container object. This is not needed for this tag.
        Specified by:
        getContainer in interface Composite
        Returns:
        the container object
      • setLayout

        public void setLayout​(Object layout)
        Sets a layout for this container. For a tabbed pane layout objects are not supported, so an exception will be thrown.
        Specified by:
        setLayout in interface Composite
        Parameters:
        layout - the layout object
      • getTabs

        public Collection<TabbedPaneTag.TabData> getTabs()
        Returns a collection with the tabs of this tabbed pane. This information will be evaluated by the component manager to create the tab pages.
        Returns:
        a collection with all defined tabs
      • process

        protected void process()
                        throws FormBuilderException,
                               org.apache.commons.jelly.JellyTagException
        Processes this tag. This implementation ensures that always a name is specified for this component - either in the script a name was defined or one is generated automatically.
        Overrides:
        process in class InputComponentTag
        Throws:
        FormBuilderException - if the tag is incorrectly used
        org.apache.commons.jelly.JellyTagException - if an error occurs
      • createComponentHandler

        protected ComponentHandler<?> createComponentHandler​(ComponentManager manager,
                                                             boolean create)
                                                      throws FormBuilderException,
                                                             org.apache.commons.jelly.JellyTagException
        Creates the component handler object for the represented component. This implementation will ask the component manager to create a tabbed pane object and its corresponding component handler.
        Specified by:
        createComponentHandler in class InputComponentTag
        Parameters:
        manager - the component handler
        create - the create flag
        Returns:
        the component handler for the new component
        Throws:
        FormBuilderException - if the tag is incorrectly used
        org.apache.commons.jelly.JellyTagException - if the tag is incorrectly used
      • generateAutoName

        protected String generateAutoName()
        Generates a name for this tabbed pane. This method is called when no name was specified. It must return a unique default name. This implementation uses the prefix defined by the AUTO_NAME_PREFIX constant and adds a serial number to it.
        Returns:
        an auto generated name for this component