Class ButtonTag

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

    public class ButtonTag
    extends ToggleButtonTag

    A specific tag handler class for creating command button components.

    A button can have a text and an icon. In addition a command string can be defined, which can be used to identify the button when an action event occurs. Though command buttons do not gather any input data, they are treated as input components, mainly due to a requirement of the event mechanism. Because the typical use case of a simple command button does not require any data to be stored for this component, this tag handler class will set the noField attribute to a default value of true. So if this attribute is not explicitly set in the Jelly script, no field will be created for the button in the generated Form object.

    The following table lists all attributes supported by this tag handler class:

    Attribute Description Optional
    text With this attribute the label's text can directly be set. yes
    textres Defines the resource ID for the label's text. The real text is resolved using the current resource manager and the current locale. yes
    resgrp Specifies the resource group of the label's text. If set, this resource group is used when resolving the label's text as defined by the textres attribute. If undefined, the form builder's default resource group will be used. yes
    alignment Defines the relative position of the label's icon to its text. This can be one of the literal names of the TextIconAlignment class. yes
    mnemonic Here a mnemonic for this label can be specified. If the user enters this key, the associated component will be focused (if supported by the platform). yes
    mnemonicres This attribute defines the mnemonic as a resource, which makes sense for i18n applications. yes
    command Allows defining a command string. Action events that are caused by this button will contain this string. yes
    default A boolean flag that indicates whether this button is the default button. The default button is automatically triggered by a UI-specific user action (typically pressing enter), even if it does not have the keyboard focus. Only one button in a form should be marked as default button. yes
    cancel A boolean flag that indicates whether this button is the cancel button for the current window. The cancel button is automatically triggered when the user presses the Escape key. If the window allows closing on Escape, the button is then triggered. Only a single button in a form should be marked as cancel button. yes

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

      • ButtonTag

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

      • isDefault

        public boolean isDefault()
        Returns a flag whether this tag represents the default button of the current form.
        Returns:
        the default button flag
      • setDefault

        public void setDefault​(boolean f)
        Set method of the default attribute.
        Parameters:
        f - the attribute's value
      • isCancel

        public boolean isCancel()
        Returns a flag whether this tag represents the cancel button of the current form.
        Returns:
        the cancel button flag
        Since:
        1.4
      • setCancel

        public void setCancel​(boolean f)
        Set method of the cancel attribute.
        Parameters:
        f - the attribute's value
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Performs processing before this tag's body is evaluated. This implementation checks whether this button is marked as default button. If so, the button's name is stored in the current ComponentBuilderData object.
        Overrides:
        processBeforeBody in class InputComponentTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is used incorrectly
        FormBuilderException - if an error occurs