com.opensymphony.webwork.views.jsp
Class BeanTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended bycom.opensymphony.webwork.views.jsp.WebWorkTagSupport
          extended bycom.opensymphony.webwork.views.jsp.BeanTag
All Implemented Interfaces:
IterationTag, ParamTag.Parametric, Serializable, Tag

public class BeanTag
extends WebWorkTagSupport
implements ParamTag.Parametric

BeanTag will instantiate a class that conforms to the JavaBeans specification. This tag has a body which can contain a number of ParamTag ParamTag elements to set any mutator methods on that class.

If the id attribute is set on the BeanTag, it will place the instantiated bean into the PageContext and the ActionContext.

Examples:

 
   
 

The value of foo is : , when inside the bean tag.

This example instantiates a bean called SimpleCounter and sets the foo property (setFoo('BAR')). The SimpleCounter object is then pushed onto the Valuestack, which means that we can called its accessor methods (getFoo()) with the Property tag and get their values.

In the above example, the id has been set to a value of counter. This means that the SimpleCounter class will be placed into the PageContext and ActionContext. You can access theah SimpleCounter class using JSTL:

 
 

or using the webwork Property tag:

 
 

In the property tag example, the # tells Ognl to search the context for the SimpleCounter class which has an id(key) of counter

Version:
$Revision: 1.14 $
Author:
$author$, Rick Salsa (rsal@mb.sympatico.ca), Brock Bulger
See Also:
Serialized Form

Field Summary
protected  Object bean
           
protected static org.apache.commons.logging.Log log
           
protected  String name
           
 
Fields inherited from class com.opensymphony.webwork.views.jsp.WebWorkTagSupport
ALT_SYNTAX
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
BeanTag()
           
 
Method Summary
 void addParameter(String key, Object value)
           
 int doEndTag()
           
 int doStartTag()
           
 Map getParameters()
           
 void setName(String name)
           
 
Methods inherited from class com.opensymphony.webwork.views.jsp.WebWorkTagSupport
findString, findValue, findValue, getStack, toString, translateVariables
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

bean

protected Object bean

name

protected String name
Constructor Detail

BeanTag

public BeanTag()
Method Detail

setName

public void setName(String name)

getParameters

public Map getParameters()
Specified by:
getParameters in interface ParamTag.Parametric

addParameter

public void addParameter(String key,
                         Object value)
Specified by:
addParameter in interface ParamTag.Parametric

doEndTag

public int doEndTag()
             throws JspException
Specified by:
doEndTag in interface Tag
Throws:
JspException

doStartTag

public int doStartTag()
               throws JspException
Specified by:
doStartTag in interface Tag
Throws:
JspException

WebWork Project Page