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
urlattribute. - By specifying a resource name using the
resourceattribute. 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 theresourceLoaderattribute. - By specifying an arbitrary
Locatorpointing to the icon data using thelocatorattribute. 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
refattribute an icon can be referenced that has already been created and stored in the Jelly context (e.g by anothericontag that had avarattribute (see below).
The icon is created using the component manager. Then the tag searches for an enclosing tag that implements the
IconSupportinterface. If one is found, this tag is passed the icon. With thevarattribute 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 (thevarattribute or anIconSupporttag) 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 ObjectcreateIcon()Creates the icon.protected LocatorfetchLocator()Fetches the locator for the icon.StringgetLocator()Returns the name of theLocator, from which the icon should be obtained.StringgetRef()Returns the name of the variable that stores the icon.StringgetResource()Returns the resource name of the icon.StringgetResourceLoader()Returns the name of the class loader for resolving the resource name.StringgetUrl()Returns the URL that points to the icon.StringgetVar()Returns the name of the variable, to which the icon should be assigned.protected voidprocess()Executes this tag.voidsetLocator(String locator)Setter method of thelocatorattribute.voidsetRef(String ref)Setter method for the var attribute.voidsetResource(String resource)Setter method for the resource attribute.voidsetResourceLoader(String resourceLoader)Setter method for theresourceLoaderattribute.voidsetUrl(String url)Setter method for the URL attribute.voidsetVar(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 theresourceLoaderattribute. 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 thelocatorattribute. With this attribute an arbitraryLocatorcan 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 ofLocatorwith the icon data
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException, FormBuilderExceptionExecutes this tag. Tries to create the icon and set it on an enclosingIconSupporttag.- Specified by:
processin 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 thelocatorattribute is specified, the locator is looked up from the current bean context. Otherwise a locator is created from the other convenience attributes (urlorresource).- Returns:
- the
Locatorthat defines the icon
-
-