Class TextListModelTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.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 thevar
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 theTextListModelTag
class: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); otherwisejava.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. Yes- Version:
- $Id: TextListModelTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
TextListModelTag.TextListModel
A simple implementation of theListModel
interface that maintains a list of display texts and a list with the corresponding values.
-
Constructor Summary
Constructors Constructor Description TextListModelTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(String display, Object value)
Adds a new item to the newly created model.protected void
process()
Executes this tag.protected void
processBeforeBody()
Called before evaluation of the tag's body.void
setType(Object c)
Setter method for the type attribute.void
setVar(String s)
Setter method for the var attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
canProcess, canProcess, convertToClass, convertToNumberWithUnit, convertToNumberWithUnit, doTag, findContainer, getBuilderData, getBuilderData, getIfName, getResourceText, getResourceText, getUnlessName, setIfName, setUnlessName
-
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
-
-
-
-
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 textvalue
- 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 classFormBaseTag
-
process
protected void process()
Executes this tag.- Specified by:
process
in classFormBaseTag
-
-