org.apache.beehive.netui.tags.databinding.invoke
Class MethodParameter

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by MethodParameter
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, INetuiTag

public class MethodParameter
extends AbstractClassicTag

A tag that is used to add an argument to a method that will be called on some object. This tag can be nested within tags that extend the AbstractCallMethod class. Those tags are:

The MethodParameter tags are used to parameterize the method that the AbstractCallMethod class will call; each methodParameter tag represents a single parameter. These tags are evaluated in order and the parameters they describe are passed in order.

Overloaded methods on an object can be invoked by setting the type attribute on each methodParameter tag that is embedded in a method invocation tag. The type name must exactly match the primitive type name or the fully qualified class name of the argument. The methodParameter tags must also be in the order that they will be passed to this method. The value of the type attribute must be an exact match of the type if it were printed after having been accessed through Java reflection.

In order to pass null as an argument to a method, the null attribute must be set on this tag. Either the null attribute or the value attribute must be set on this tag.

This example shows how to pass parameters to the method call foo(int integer, String string).

    <netui-data:methodParamter value="42"/>
    <netui-data:methodParamter null="true"/>
 
This will correspond to the method call:
     foo(42, null);
 
The following sample shows how to pass parameters to the method call foo(int integer, String string) where the class has both of the methods foo(int integer, String string) and foo(Integer integer, String string).
     <netui-data:methodParamter type="int" value="42"/>
     <netui-data:methodParamter type="java.lang.String" null="true"/>
 
This will correspond to the method call:
     foo(42, null);
 

See Also:
Serialized Form
Example

This example shows how to pass parameters to the method call foo(int integer, String string).

    <netui-data:methodParamter value="42"/>
    <netui-data:methodParamter null="true"/>
 
This will correspond to the method call:
     foo(42, null);
 
The following sample shows how to pass parameters to the method call foo(int integer, String string) where the class has both of the methods foo(int integer, String string) and foo(Integer integer, String string).
     <netui-data:methodParamter type="int" value="42"/>
     <netui-data:methodParamter type="java.lang.String" null="true"/>
 
This will correspond to the method call:
     foo(42, null);
 


Field Summary
static Integer NULL_ARG
          An identifier denoting that the value of this method parameter should be treated as 'null'.
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
MethodParameter()
           
 
Method Summary
 int doEndTag()
          Prepare the value to pass up to the AbstractCallMethod type parent.
 int doStartTag()
          Start this tag's lifecycle.
 String getTagName()
          Get the name of this tag.
protected  void localRelease()
          Reset all of the fields of this tag.
 void setNull(boolean isNull)
          Sets a boolean that describes that the parameter that should be passed to the method is null.
 void setType(String type)
          

Set a String matching the type of this parameter on the method to invoke.

 void setValue(Object value)
          Sets the value of the method parameter that will be passed to the method call.
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNamingChain, getNearestForm, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Field Detail

NULL_ARG

public static final Integer NULL_ARG
An identifier denoting that the value of this method parameter should be treated as 'null'.

Constructor Detail

MethodParameter

public MethodParameter()
Method Detail

getTagName

public String getTagName()
Get the name of this tag. This is used to identify the type of this tag for reporting tag errors.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
a constant String representing the name of this tag.

setType

public void setType(String type)

Set a String matching the type of this parameter on the method to invoke.

This name should match the primitive type name or fully qualified class name of the parameters on the signature of the method to which this parameter will be passed.

For example:

Method SignatureArgument NameType value
addToPrice(int price)priceint
addToPrice(Integer price)pricejava.lang.Integer

Parameters:
type - the type name

setValue

public void setValue(Object value)
Sets the value of the method parameter that will be passed to the method call. This String can be an expression. If the value is not an expression that references an Ojbect, the AbstractCallMethod.doEndTag() will attempt to convert the String to type that matches the position of the MethodParameter tag in the list of MethodParameter tags nested inside of an AbstractCallMethod tag.

Parameters:
value - a String value which may be an expression

setNull

public void setNull(boolean isNull)
Sets a boolean that describes that the parameter that should be passed to the method is null.

Parameters:
isNull - a value that describes whether or not this tag should pass null; if true null will be passed; otherwise the value from the value attribute will be passed.

doStartTag

public int doStartTag()
               throws JspException
Start this tag's lifecycle. Verify that this tag is nested within a AbstractCallMethod tag and that one of the "null" and "value" attributes are set.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Returns:
Tag.SKIP_BODY
Throws:
JspException - if an error occurs getting the parameter

doEndTag

public int doEndTag()
             throws JspException
Prepare the value to pass up to the AbstractCallMethod type parent.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Returns:
Tag.EVAL_PAGE to continue evaluating the page
Throws:
JspException

localRelease

protected void localRelease()
Reset all of the fields of this tag.

Overrides:
localRelease in class AbstractClassicTag