Class IconTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.IconTag
-
- All Implemented Interfaces:
ConditionalTag
,org.apache.commons.jelly.Tag
public class IconTag extends FormBaseTag
A tag for adding an icon to a component.
This tag supports multiple ways for defining an icon:
- By specifying an URL using the
url
attribute. - By specifying a resource name using the
resource
attribute. In this case the icon is searched on the class path. Per default, the current default class loader is used for resolving the resource name. If a different class loader is desired, its name (as registered at the currentClassLoaderProvider
) can be specified using theresourceLoader
attribute. - By specifying an arbitrary
Locator
pointing to the icon data using thelocator
attribute. This is actually the generic form of the ways described above. The locator is looked up by its name in the current bean context. - With the
ref
attribute an icon can be referenced that has already been created and stored in the Jelly context (e.g by anothericon
tag that had avar
attribute (see below).
The icon is created using the component manager. Then the tag searches for an enclosing tag that implements the
IconSupport
interface. If one is found, this tag is passed the icon. With thevar
attribute the name of a variable can be specified, which is assigned the icon. So it can be reused. At least one of the ways for storing an icon (thevar
attribute or anIconSupport
tag) must be defined, otherwise an exception is thrown.- Version:
- $Id: IconTag.java 211 2012-07-10 19:49:13Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description IconTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
createIcon()
Creates the icon.protected Locator
fetchLocator()
Fetches the locator for the icon.String
getLocator()
Returns the name of theLocator
, from which the icon should be obtained.String
getRef()
Returns the name of the variable that stores the icon.String
getResource()
Returns the resource name of the icon.String
getResourceLoader()
Returns the name of the class loader for resolving the resource name.String
getUrl()
Returns the URL that points to the icon.String
getVar()
Returns the name of the variable, to which the icon should be assigned.protected void
process()
Executes this tag.void
setLocator(String locator)
Setter method of thelocator
attribute.void
setRef(String ref)
Setter method for the var attribute.void
setResource(String resource)
Setter method for the resource attribute.void
setResourceLoader(String resourceLoader)
Setter method for theresourceLoader
attribute.void
setUrl(String url)
Setter method for the URL attribute.void
setVar(String var)
Setter method of 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, processBeforeBody, 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
-
getResource
public String getResource()
Returns the resource name of the icon.- Returns:
- the resource name
-
setResource
public void setResource(String resource)
Setter method for the resource attribute. Specifies the name under which the icon can be found on the classpath. Either this resource name or an URL must be specified.- Parameters:
resource
- the resource name
-
getResourceLoader
public String getResourceLoader()
Returns the name of the class loader for resolving the resource name.- Returns:
- the name of the class loader
- Since:
- 1.2
-
setResourceLoader
public void setResourceLoader(String resourceLoader)
Setter method for theresourceLoader
attribute. Here the name of a class loader for resolving the resource name can be provided. A class loader with this name is looked up using the currentClassLoaderProvider
. If no class loader has been specified, the default one is used.- Parameters:
resourceLoader
- the name of the class loader for resolving class path resources- Since:
- 1.2
-
getUrl
public String getUrl()
Returns the URL that points to the icon.- Returns:
- the URL
-
setUrl
public void setUrl(String url)
Setter method for the URL attribute. Specifies an URL from which the icon can be loaded. Either this URL or a resource name must be specified.- Parameters:
url
- the URL
-
getRef
public String getRef()
Returns the name of the variable that stores the icon.- Returns:
- the name of a variable reference
-
setRef
public void setRef(String ref)
Setter method for the var attribute. If no URL or resource name are specified, the icon can be obtained from a variable.- Parameters:
ref
- the attribute's value
-
getVar
public String getVar()
Returns the name of the variable, to which the icon should be assigned.- Returns:
- the name of a target variable
-
setVar
public void setVar(String var)
Setter method of the var attribute.- Parameters:
var
- the attribute's value
-
getLocator
public String getLocator()
Returns the name of theLocator
, from which the icon should be obtained.- Returns:
- the name of the
Locator
-
setLocator
public void setLocator(String locator)
Setter method of thelocator
attribute. With this attribute an arbitraryLocator
can be specified, from which the icon data is loaded. The locator is looked up in the current bean context under the name specified here.- Parameters:
locator
- the name ofLocator
with the icon data
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException, FormBuilderException
Executes this tag. Tries to create the icon and set it on an enclosingIconSupport
tag.- Specified by:
process
in classFormBaseTag
- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occursFormBuilderException
- if an error occurs
-
createIcon
protected Object createIcon() throws FormBuilderException
Creates the icon. This method is called after all syntactic checks were successful. Here the icon must be created, depending on the defined attributes.- Returns:
- the icon
- Throws:
FormBuilderException
- if an error occurs
-
fetchLocator
protected Locator fetchLocator()
Fetches the locator for the icon. This method is called bycreateIcon()
when no reference attribute is specified, i.e. the icon has to be obtained from a locator. If thelocator
attribute is specified, the locator is looked up from the current bean context. Otherwise a locator is created from the other convenience attributes (url
orresource
).- Returns:
- the
Locator
that defines the icon
-
-