Class TextListModelTag

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

    public class TextListModelTag
    extends FormBaseTag

    A tag handler class that creates a text based ListModel.

    This tag creates a list model whose values can be immediately defined in the jelly script. This is appropriate for simple combo boxes or list boxes that only display a fixed set of items. The model's content is defined by tags in the body of this tag.

    After the model has been created and initialized by the tag's body this tag tries to find an enclosing tag that implements the ListModelSupport interface. If such a tag can be found, it is passed the newly created model. It is also possible to specify a name for the new model using the var attribute. The new model will then be stored in the jelly context, where it can be accessed by other components.

    With the addItem(String, Object) method new text items can be added to the list model. This method will be called by specific tags that are intended to be placed in this tag's body. This method expects a text label that is displayed in the UI and an optional value; if the text is selected in the list component, the corresponding value object is written into the form data. If necessary, a type conversion is performed to the model's value type. The following table lists the attributes supported by the TextListModelTag class:

    Yes
    Attribute Description Optional
    type The data type class of the values of the data model created by this tag. Values specified for this model are automatically converted to this data type. If no value data type is specified, the type depends on the values specified for model elements: if values are defined, it is set to java.lang.Integer (representing the index of the selected item); otherwise java.lang.String is assumed. Yes
    var With this attribute a variable name can be specified under which the model created by this tag is stored in the Jelly context. Using this variable the model can be accessed by other components.

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

      • TextListModelTag

        public TextListModelTag()
    • Method Detail

      • setType

        public void setType​(Object c)
        Setter method for the type attribute.
        Parameters:
        c - the attribute value
      • setVar

        public void setVar​(String s)
        Setter method for the var attribute.
        Parameters:
        s - the attribute's value
      • addItem

        public void addItem​(String display,
                            Object value)
        Adds a new item to the newly created model.
        Parameters:
        display - the display text
        value - the corresponding value (can be null )
      • processBeforeBody

        protected void processBeforeBody()
        Called before evaluation of the tag's body. Creates the list model object.
        Overrides:
        processBeforeBody in class FormBaseTag
      • process

        protected void process()
        Executes this tag.
        Specified by:
        process in class FormBaseTag