org.apache.commons.jelly.tags.swing
Class ComponentTag

java.lang.Object
  extended byorg.apache.commons.jelly.TagSupport
      extended byorg.apache.commons.jelly.DynaTagSupport
          extended byorg.apache.commons.jelly.MapTagSupport
              extended byorg.apache.commons.jelly.tags.core.UseBeanTag
                  extended byorg.apache.commons.jelly.tags.swing.ComponentTag
All Implemented Interfaces:
org.apache.commons.jelly.impl.BeanSource, ContainerTag, org.apache.commons.jelly.DynaTag, org.apache.commons.jelly.Tag
Direct Known Subclasses:
ButtonGroupTag

public class ComponentTag
extends org.apache.commons.jelly.tags.core.UseBeanTag
implements ContainerTag

This tag creates a Swing component and adds it to its parent tag, optionally declaring this component as a variable if the var attribute is specified.

This tag clears the reference to it's bean after doTag runs. This means that child tags can access the component (bean) normally during execution but should not hold a reference to this tag after their doTag completes.

Version:
$Revision: 331171 $
Author:
James Strachan

Field Summary
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
ComponentTag()
           
ComponentTag(Factory factory)
           
 
Method Summary
 void addChild(java.awt.Component component, java.lang.Object constraints)
          Adds a child component to this parent
 void addFocusListener(java.awt.event.FocusListener listener)
          Adds a FocusListener to this component
 void addKeyListener(java.awt.event.KeyListener listener)
          Adds a KeyListener to this component
 void addWindowListener(java.awt.event.WindowListener listener)
          Adds a WindowListener to this component
protected  void clearBean()
          Sets the bean to null, to prevent it from sticking around in the event that this tag instance is cached.
protected  java.lang.Class convertToClass(java.lang.Object classObject)
          A class may be specified otherwise the Factory will be used.
 void doTag(org.apache.commons.jelly.XMLOutput output)
          Overrides the default UseBean functionality to clear the bean after the tag runs.
 java.awt.Component getComponent()
           
protected  java.lang.Object getConstraint()
           
protected  java.lang.Object newInstance(java.lang.Class theClass, java.util.Map attributes, org.apache.commons.jelly.XMLOutput output)
          A class may be specified otherwise the Factory will be used.
protected  void processBean(java.lang.String var, java.lang.Object bean)
          Either defines a variable or adds the current component to the parent
 void setAction(javax.swing.Action action)
          Sets the Action of this component
protected  void setBeanProperties(java.lang.Object bean, java.util.Map attributes)
          Handles wierd properties that don't quite match the Java Beans contract
 void setBorder(javax.swing.border.Border border)
          Sets the Border of this component
 void setFont(java.awt.Font font)
          Sets the Font of this component
 void setLayout(java.awt.LayoutManager layout)
          Sets the LayoutManager of this component
 void setTagName(java.lang.String name)
          Puts this tag into the context under the given name allowing later calls to #rerun().
 java.lang.String toString()
           
 
Methods inherited from class org.apache.commons.jelly.tags.core.UseBeanTag
addIgnoreProperty, getBean, getDefaultClass, getIgnorePropertySet, isIgnoreUnknownProperties, loadClass, setBean, setIgnoreUnknownProperties, validateBeanProperties
 
Methods inherited from class org.apache.commons.jelly.MapTagSupport
createAttributes, getAttributes, setAttribute
 
Methods inherited from class org.apache.commons.jelly.DynaTagSupport
getAttributeType
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
 

Constructor Detail

ComponentTag

public ComponentTag()

ComponentTag

public ComponentTag(Factory factory)
Method Detail

toString

public java.lang.String toString()

setAction

public void setAction(javax.swing.Action action)
               throws org.apache.commons.jelly.JellyTagException
Sets the Action of this component

Throws:
org.apache.commons.jelly.JellyTagException

setFont

public void setFont(java.awt.Font font)
             throws org.apache.commons.jelly.JellyTagException
Sets the Font of this component

Throws:
org.apache.commons.jelly.JellyTagException

setBorder

public void setBorder(javax.swing.border.Border border)
               throws org.apache.commons.jelly.JellyTagException
Sets the Border of this component

Throws:
org.apache.commons.jelly.JellyTagException

setLayout

public void setLayout(java.awt.LayoutManager layout)
               throws org.apache.commons.jelly.JellyTagException
Sets the LayoutManager of this component

Throws:
org.apache.commons.jelly.JellyTagException

setTagName

public void setTagName(java.lang.String name)
Puts this tag into the context under the given name allowing later calls to #rerun(). For example, it makes sense to use ${myTag.rerun()} as a child of an action element.


addWindowListener

public void addWindowListener(java.awt.event.WindowListener listener)
                       throws org.apache.commons.jelly.JellyTagException
Adds a WindowListener to this component

Throws:
org.apache.commons.jelly.JellyTagException

addFocusListener

public void addFocusListener(java.awt.event.FocusListener listener)
                      throws org.apache.commons.jelly.JellyTagException
Adds a FocusListener to this component

Throws:
org.apache.commons.jelly.JellyTagException

addKeyListener

public void addKeyListener(java.awt.event.KeyListener listener)
                    throws org.apache.commons.jelly.JellyTagException
Adds a KeyListener to this component

Throws:
org.apache.commons.jelly.JellyTagException

getComponent

public java.awt.Component getComponent()
Returns:
the visible component, if there is one.

addChild

public void addChild(java.awt.Component component,
                     java.lang.Object constraints)
              throws org.apache.commons.jelly.JellyTagException
Adds a child component to this parent

Specified by:
addChild in interface ContainerTag
Throws:
org.apache.commons.jelly.JellyTagException

convertToClass

protected java.lang.Class convertToClass(java.lang.Object classObject)
                                  throws org.apache.commons.jelly.MissingAttributeException,
                                         java.lang.ClassNotFoundException
A class may be specified otherwise the Factory will be used.

Throws:
org.apache.commons.jelly.MissingAttributeException
java.lang.ClassNotFoundException

newInstance

protected java.lang.Object newInstance(java.lang.Class theClass,
                                       java.util.Map attributes,
                                       org.apache.commons.jelly.XMLOutput output)
                                throws org.apache.commons.jelly.JellyTagException
A class may be specified otherwise the Factory will be used.

Throws:
org.apache.commons.jelly.JellyTagException

processBean

protected void processBean(java.lang.String var,
                           java.lang.Object bean)
                    throws org.apache.commons.jelly.JellyTagException
Either defines a variable or adds the current component to the parent

Throws:
org.apache.commons.jelly.JellyTagException

setBeanProperties

protected void setBeanProperties(java.lang.Object bean,
                                 java.util.Map attributes)
                          throws org.apache.commons.jelly.JellyTagException
Handles wierd properties that don't quite match the Java Beans contract

Throws:
org.apache.commons.jelly.JellyTagException

getConstraint

protected java.lang.Object getConstraint()

doTag

public void doTag(org.apache.commons.jelly.XMLOutput output)
           throws org.apache.commons.jelly.JellyTagException
Overrides the default UseBean functionality to clear the bean after the tag runs. This prevents us from keeping references to heavy Swing objects around for longer than they are needed.

Specified by:
doTag in interface org.apache.commons.jelly.Tag
Throws:
org.apache.commons.jelly.JellyTagException
See Also:
Tag.doTag(org.apache.commons.jelly.XMLOutput)

clearBean

protected void clearBean()
Sets the bean to null, to prevent it from sticking around in the event that this tag instance is cached. This method is called at the end of doTag.



Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.