Class LabelTag

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

    public class LabelTag
    extends TextIconTag

    A tag class for creating labels.

    This tag will create a simple label and add it to the enclosing container object. Because a label does not gather any user input, it is not added to the current form object. The following attributes are supported by label tags:

    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
    componentref With this attribute the name of an associated component can be specified. If set and if supported by the current platform, the label can be used to focus this component. There must be a component with the name given here. yes

    The label tag supports an icon, which can be defined by an IconTag in the tag's body. If a label is associated with another component (by using the componentref attribute), it is possible to obtain the text from the display name of this component. This is automatically done if neither a text nor an icon is defined. This is a very convenient way of creating a label. If the componentref attribute is undefined, a text or an icon must be defined; otherwise an exception will be thrown.

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

      • LabelTag

        public LabelTag()
    • Method Detail

      • getComponentref

        public String getComponentref()
        Returns the name of the component this label is associated with.
        Returns:
        the associated component
      • setComponentref

        public void setComponentref​(String component)
        Setter method of the componentref attribute.
        Parameters:
        component - the attribute value
      • createComponent

        protected Object createComponent​(ComponentManager manager,
                                         boolean create)
                                  throws org.apache.commons.jelly.MissingAttributeException,
                                         FormBuilderException
        Creates the label component.
        Specified by:
        createComponent in class SimpleComponentTag
        Parameters:
        manager - the component manager
        create - the create flag
        Returns:
        the new label component
        Throws:
        org.apache.commons.jelly.MissingAttributeException - if required attributes are missing
        FormBuilderException - if an error occurs creating the component