Class ButtonTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- All Implemented Interfaces:
ConditionalTag
,IconSupport
,org.apache.commons.jelly.Tag
public class ButtonTag extends ToggleButtonTag
A specific tag handler class for creating command button components.
A button can have a text and an icon. In addition a command string can be defined, which can be used to identify the button when an action event occurs. Though command buttons do not gather any input data, they are treated as input components, mainly due to a requirement of the event mechanism. Because the typical use case of a simple command button does not require any data to be stored for this component, this tag handler class will set the
noField
attribute to a default value of true. So if this attribute is not explicitly set in the Jelly script, no field will be created for the button in the generatedForm
object.The following table lists all attributes supported by this tag handler class:
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 command
Allows defining a command string. Action events that are caused by this button will contain this string. yes default
A boolean flag that indicates whether this button is the default button. The default button is automatically triggered by a UI-specific user action (typically pressing enter), even if it does not have the keyboard focus. Only one button in a form should be marked as default button. yes cancel
A boolean flag that indicates whether this button is the cancel button for the current window. The cancel button is automatically triggered when the user presses the Escape key. If the window allows closing on Escape, the button is then triggered. Only a single button in a form should be marked as cancel button. yes - Version:
- $Id: ButtonTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description ButtonTag()
Creates a new instance ofButtonTag
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ComponentHandler<Boolean>
createPushButton(ComponentManager manager, boolean create)
Creates the new command button component.boolean
isCancel()
Returns a flag whether this tag represents the cancel button of the current form.boolean
isDefault()
Returns a flag whether this tag represents the default button of the current form.protected void
processBeforeBody()
Performs processing before this tag's body is evaluated.void
setCancel(boolean f)
Set method of thecancel
attribute.void
setDefault(boolean f)
Set method of thedefault
attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.ToggleButtonTag
getCommand, setCommand
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.PushButtonTag
createComponentHandler, getTextIconData, setAlignment, setIcon, setMnemonic, setMnemonicres, setResgrp, setText, setTextres, validateTag
-
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, 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
-
isDefault
public boolean isDefault()
Returns a flag whether this tag represents the default button of the current form.- Returns:
- the default button flag
-
setDefault
public void setDefault(boolean f)
Set method of thedefault
attribute.- Parameters:
f
- the attribute's value
-
isCancel
public boolean isCancel()
Returns a flag whether this tag represents the cancel button of the current form.- Returns:
- the cancel button flag
- Since:
- 1.4
-
setCancel
public void setCancel(boolean f)
Set method of thecancel
attribute.- Parameters:
f
- the attribute's value
-
createPushButton
protected ComponentHandler<Boolean> createPushButton(ComponentManager manager, boolean create) throws FormBuilderException
Creates the new command button component.- Overrides:
createPushButton
in classToggleButtonTag
- Parameters:
manager
- the component managercreate
- the create flag- Returns:
- the component handler for the newly created button
- Throws:
FormBuilderException
- if an error occurs
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagException, FormBuilderException
Performs processing before this tag's body is evaluated. This implementation checks whether this button is marked as default button. If so, the button's name is stored in the currentComponentBuilderData
object.- Overrides:
processBeforeBody
in classInputComponentTag
- Throws:
org.apache.commons.jelly.JellyTagException
- if the tag is used incorrectlyFormBuilderException
- if an error occurs
-
-