Class StaticTextTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.ComponentBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.InputComponentTag
-
- net.sf.jguiraffe.gui.builder.components.tags.PushButtonTag
-
- net.sf.jguiraffe.gui.builder.components.tags.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 theComponentBuilderData
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 thatmyStatic
is the name of a static text element andbuilderData
is an instance ofComponentBuilderData
):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 thesetData()
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 theLabelTag
, 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 Summary
Constructors Constructor Description StaticTextTag()
Creates a new instance ofStaticTextTag
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ComponentHandler<?>
createPushButton(ComponentManager manager, boolean create)
Creates the element.protected void
validateTag()
Performs a validation for this tag.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.PushButtonTag
createComponentHandler, getTextIconData, setAlignment, setIcon, setMnemonic, setMnemonicres, setResgrp, setText, setTextres
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.InputComponentTag
addToGroups, checkName, createFieldHandler, getComponent, getComponentHandler, getComponentType, getDisplayName, getFieldValidator, getFormValidator, getGroups, getPropertyName, getReadTransformer, getTypeName, getWriteTransformer, handleGroups, insertField, isNoField, process, processBeforeBody, setComponentType, setDisplayName, setDisplayNamegrp, setDisplayNameres, setFieldValidator, setFormValidator, setGroups, setNoField, setPropertyName, setReadTransformer, setTypeName, setWriteTransformer
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.ComponentBaseTag
getBackColor, getBackgroundColor, getConstraints, getFont, getFontRef, getForeColor, getForegroundColor, getName, getToolTipData, insertComponent, setBackColor, setConstraints, setFont, setFontRef, setForeColor, setName, setTooltip, setTooltipres, setTooltipresgrp
-
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
-
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 classPushButtonTag
- Throws:
FormBuilderException
- if the tag is incorrectly usedorg.apache.commons.jelly.MissingAttributeException
- if a required attribute is missing
-
createPushButton
protected ComponentHandler<?> createPushButton(ComponentManager manager, boolean create) throws FormBuilderException
Creates the element. This implementation will create a static text element using the specified component manager.- Specified by:
createPushButton
in classPushButtonTag
- Parameters:
manager
- the component managercreate
- the create flag- Returns:
- the component handler for the newly created element
- Throws:
FormBuilderException
- if an error occurs
-
-