Class StaticTextTag

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

    public class StaticTextTag
    extends PushButtonTag

    A tag handler class for creating a static text component.

    A static text is very similar to a label. The main difference is that it is treated as an input component and can thus be addressed by name and manipulated. Per default a static text component won't become part of the form that is constructed during the build operation. But for it a ComponentHandler object is created that can be obtained from the ComponentBuilderData object. This handler can be used to manipulate the data of the static text.

    The properties of a static text are its text, its icon, and the alignment between the two. They can be read and written using objects of type StaticTextData. This can be done in the following way (assuming that myStatic is the name of a static text element and builderData is an instance of ComponentBuilderData):

     ComponentHandler handler = builderData.getComponentHandler("myStatic");
     StaticTextData data = (StaticTextData) handler.getData();
     // set a new text
     data.setText("Some new text");
     handler.setData(data);
     

    Note that it is not sufficient to simply manipulate the StaticTextData object. Instead the altered object must be passed again to the setData() method of the component handler. The ability of being altered after the creation makes static text elements suitable for implementing dynamic labels. So simple labels, which won't be changed during the life time of a form, can be realized using the LabelTag, while this tag allows for instance labels whose text or icon is based on some calculations or change dynamically. The following attributes are supported by this tag handler class (in addition to the default attributes allowed for all input component 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
    noField This boolean standard attribute determines whether this element is to be added to the form object. In contrast to most of the other input components it has a default value of true, meaning that static text elements are not part of the constructed form. If desired, this can be manually set to false. Yes

    This tag supports an icon, which can be defined by an IconTag in the tag's body. It is supported to define neither a text nor an icon. The static text's content may then be defined later.

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

      • StaticTextTag

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

      • validateTag

        protected void validateTag()
                            throws FormBuilderException,
                                   org.apache.commons.jelly.MissingAttributeException
        Performs a validation for this tag. For a static text element no validation is needed because completely undefined tags are allowed, too.
        Overrides:
        validateTag in class PushButtonTag
        Throws:
        FormBuilderException - if the tag is incorrectly used
        org.apache.commons.jelly.MissingAttributeException - if a required attribute is missing