Class MenuTag

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

    public class MenuTag
    extends FormBaseTag
    implements ActionContainer, IconSupport

    A tag handler class for defining menus.

    With this tag handler a menu object can be defined that belongs to a menu bar. This menu is defined by a text, a mnemonic, and an optional icon (not all platforms may support icons for menus). Text and/or mnemonic can be specified either directly or as resource IDs.

    The following table lists all supported attributes:

    Attribute Description Optional
    text With this attribute the menu's text can directly be set. yes
    textres Defines the resource ID for the menu's text. The real text is resolved using the current resource manager and the current locale. yes
    resgrp Specifies the resource group of the menu's text. If set, this resource group is used when resolving the menu's text as defined by the textres attribute. If undefined, the form builder's default resource group will be used. yes
    mnemonic Here a mnemonic for this menu can be specified. yes
    mnemonicres This attribute defines the mnemonic as a resource, which makes sense for i18n applications. yes

    In this tag's body an icon tag can be placed to define the icon for the menu.

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

      • MenuTag

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

      • getData

        public TextIconData getData()
        Returns the definition data for this menu.
        Returns:
        the data for this menu
      • getContainer

        public Object getContainer()
        Returns the container maintained by this tag. This implementation returns the menu object.
        Specified by:
        getContainer in interface ActionContainer
        Returns:
        the container object
      • setIcon

        public void setIcon​(Object icon)
        Sets the icon for this menu.
        Specified by:
        setIcon in interface IconSupport
        Parameters:
        icon - the icon
      • setText

        public void setText​(String s)
        Setter method for the text attribute.
        Parameters:
        s - the attribute value
      • setTextres

        public void setTextres​(String s)
        Setter method for the textres attribute.
        Parameters:
        s - the attribute value
      • setResgrp

        public void setResgrp​(String s)
        Setter method for the resgrp attribute.
        Parameters:
        s - the attribute value
      • setMnemonic

        public void setMnemonic​(String s)
        Setter method for the mnemonic attribute.
        Parameters:
        s - the attribute value
      • setMnemonicres

        public void setMnemonicres​(String s)
        Setter method for the mnemonicres attribute.
        Parameters:
        s - the attribute value
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Executes this tag before its body is processed. This implementation creates the menu object and stores it in an internal member field.
        Overrides:
        processBeforeBody in class FormBaseTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is not used correctly
        FormBuilderException - if an error occurs
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException,
                               FormBuilderException
        Executes this tag. Performs further initialization of the menu.
        Specified by:
        process in class FormBaseTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is not used correctly
        FormBuilderException - if an error occurs
      • findParentMenu

        protected Object findParentMenu()
                                 throws org.apache.commons.jelly.JellyTagException
        Tries to find the parent menu to which this menu has to be added. This can be either a menu bar or another menu this menu is a sub menu from. If neither a nesting menu bar tag nor a menu tag can be found, an exception will be thrown.
        Returns:
        the parent menu
        Throws:
        org.apache.commons.jelly.JellyTagException - if no parent can be found
      • findParentContainer

        protected ActionContainer findParentContainer()
        Tries to find the action container for the parent menu. This tag can occur inside a menu bar tag or a menu tag. If none of these is found, null is returned.
        Returns:
        the parent menu container
      • getActionBuilder

        protected ActionBuilder getActionBuilder()
        Returns a reference to the current ActionBuilder instance. This instance is expected to be placed in the Jelly context.
        Returns:
        the current action builder
      • getActionManager

        protected ActionManager getActionManager()
        Convenience method for obtaining a reference to the current ActionManager.
        Returns:
        the current action manager