AbstractCallMethod Class

com.bea.wlw.netui.tags.databinding.invoke
AbstractCallMethod Class

public abstract class AbstractCallMethod

    extends AbstractBaseTag

An abstract base class for tags that are capable of reflectively invoking methods. Specializations of this tag provide method implementations that locate the object on which to invoke the method and that handle any return value from the invoked method.

The CallMethod tag can have child tags of type MethodParameter; these tags must be in the same order as the parameter list in the method signature of the method that will be invoked. To invoke an overloaded method, the property must be set to the String name of the type to pass to the method. If the type attribute values on nested MethodParameter tags do not match any method signature, an error will be reported in the page.

Attribute Descriptions
AttributeRequiredRuntime Expression EvaluationData Bindable
methodNoNoNo
The method to invoke on an object.
failOnErrorNoNoNo
A boolean that if true will cause the tag to report any method invocation errors in-line in the rendered page.
resultIdNoNoNo
The PageContext attribute name where the result, if non-null, is stored.


Hierarchy
Object
  TagSupport
    BodyTagSupport
      AbstractBaseTag
        AbstractCallMethod
All Implemented Interfaces

BodyTag, IterationTag, Serializable, Tag
Direct Known Subclasses

CallControl, CallMethod

Field Summary

   
Fields from  com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, CLASS, ID, JAVASCRIPT_STATUS, NAME, NETUI_UNIQUE_CNT, ONCLICK, ONDBLCLICK, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, STYLE, TABINDEX
 
Fields from  javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields from  javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 

Constructor Summary

AbstractCallMethod()

 

Method Summary

public void
addParameter(String type, Object parameter)
Add a paramter that will be passed as an argument to the method that will be invoked.
public int
doEndTag()
Reflectively invokes the method specified by the method attribute, AbstractCallMethod.getMethod().
public int
doStartTag()
Causes the body of this tag to be rendered; only MethodParameter tags are allowed to be contained inside of this tag.
protected Method
findMethod(Object target, String methodName, boolean verifyTypes)
The default findMethod implementation is an uncached search of all of the methods available on the Class of the target
public boolean
getFailOnError()
Get whether or not errors invoking a method are reported in-line when the tag renders.
public String
getMethod()
Gets the name of the method to invoke on the target object.
protected abstract String
getObjectName()
Get the name of the object that is the target of the invocation.
protected List
getParameterNodes()
Internal, read-only property used by subclasses to get the list of parameters to be used when reflectively invoking a method.
public String
getResultId()
Get the identifier at which the result of invoking the method can be found.
protected void
handleReturnValue(Object result)

A method that allows concrete classes to handle the result of the reflective invocation in an implementation specific way.

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

Resolve the object on which the method should be invoked.

public void
setFailOnError(boolean failOnError)
Sets whether or not to report exceptions to the page when errors occur invoking a method on an object.
public void
setMethod(String method)
Sets the name of a method to invoke on the target object.
public void
setResultId(String resultId)
Sets the identifier at which the result of invoking the method will stored.
 
Methods from  com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, evaluateAttributeToString, filter, filter, getJavaScriptUtils, getNearestForm, getScriptReporter, getTagName, getUserLocale, registerTagError, release, renderAttribute, rewriteName, write
 
Methods from  javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods from  javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface javax.servlet.jsp.tagext.BodyTag
doInitBody, setBodyContent
 
Methods from interface javax.servlet.jsp.tagext.IterationTag
doAfterBody
 
Methods from interface javax.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
 

Constructor Detail

AbstractCallMethod

public AbstractCallMethod()
 

Method Detail

addParameter(String, Object) Method

public void addParameter(String type, 
                         Object parameter)
Add a paramter that will be passed as an argument to the method that will be invoked. This method is implemented to allow the the MethodParameter tags to register their parameters. This object is passed in the position that it appeared in the set of child MethodParameter tags.

Parameters

type
a String of the type or class name of this parameter
parameter
an object that should be passed as an argument to the invoked method

Related Topics

MethodParameter


doEndTag() Method

public int doEndTag()
throws JspException
Reflectively invokes the method specified by the method attribute, AbstractCallMethod.getMethod(). The arguments passed to the method are taken from any nested MethodParameter tags. When the parameters which are added by the MethodParameter tags are String types, an attempt is made to convert each of these parameters into the type expected by the method. This conversion is done using the TypeUtils.convertToObject(String, Class) method. If a String can not be converted do the type expected by the method, an exception is thrown and the error is reported in the tag. Any return value that results from invoking the given method is passed to the subclass implementation of the method AbstractCallMethod.handleReturnValue(Object).

Overrides
BodyTagSupport.doEndTag()

Returns

EVAL_PAGE to continue evaluating the page

Exceptions

JspException
if there are errors. All exceptions that may be thrown in the process of reflectively invoking the method and performing type conversion are reported as @see javax.servlet.jsp.JspException.

Related Topics

AbstractCallMethod.getMethod()
AbstractCallMethod.handleReturnValue(Object)
MethodParameter
ObjectNotFoundException
TypeUtils.convertToObject(String, Class)
String


doStartTag() Method

public int doStartTag()
throws JspException
Causes the body of this tag to be rendered; only MethodParameter tags are allowed to be contained inside of this tag. The body content is never rendered.

Overrides
BodyTagSupport.doStartTag()

Returns

EVAL_BODY_BUFFERED

Exceptions

JspException

Related Topics

MethodParameter


findMethod(Object, String, boolean) Method

protected Method findMethod(Object target, 
                            String methodName, 
                            boolean verifyTypes)
The default findMethod implementation is an uncached search of all of the methods available on the Class of the target

Parameters

target
the object from which to find the method
methodName
the name of the method to find
verifyTypes
a boolean that if true will match the type names in addition to the String method name

Returns

a Method object matching the methodName and types, if verifyTypes is true. null otherwise.

getFailOnError() Method

public boolean getFailOnError()
Get whether or not errors invoking a method are reported in-line when the tag renders.

Returns

a boolean that if true will report errors encountered during the tag's execution.

getMethod() Method

public String getMethod()
Gets the name of the method to invoke on the target object.

Returns

the name of the method to invoke

getObjectName() Method

protected abstract String getObjectName()
Get the name of the object that is the target of the invocation. This is a generic method for this tag that enables more specific error reporting.

Returns

a name for the object on which the method will be invoked.

getParameterNodes() Method

protected List getParameterNodes()
Internal, read-only property used by subclasses to get the list of parameters to be used when reflectively invoking a method. If the method takes no parameters, this list will be of size zero.

Returns

the list of parameters

getResultId() Method

public String getResultId()
Get the identifier at which the result of invoking the method can be found.

Returns

a String where the result object can be found in the PageContext attribute map.

handleReturnValue(Object) Method

protected void handleReturnValue(Object result)

A method that allows concrete classes to handle the result of the reflective invocation in an implementation specific way.

The default beahavior is to set the return value resulting from invoking the method in the PageContext attribute map of the current JSP page. The result is set as an attribute if the result is not null and the CallMethod.getResultId() String is not null. If the value returned from calling a method is null and the CallMethod.getResultId() is non-null, the is called to remove the attribute from the attribute map.

Parameters

result
the object that was returned by calling the method on the object

localRelease() Method

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

Overrides
AbstractBaseTag.localRelease()

resolveObject() Method

protected abstract Object resolveObject()
throws ObjectNotFoundException

Resolve the object on which the method should be invoked. If there are errors resolving this object, this method will throw an ObjectNotFoundException.

If the object is not found but no exception occurred, this method should return null.

Returns

the object on which to reflectively invoke the method.

Exceptions

ObjectNotFoundException
if an exception occurred attempting to resolve an object

setFailOnError(boolean) Method

public void setFailOnError(boolean failOnError)
Sets whether or not to report exceptions to the page when errors occur invoking a method on an object.

Parameters

failOnError
a boolean that defines whether or not exceptions should be thrown when invocation fails.

setMethod(String) Method

public void setMethod(String method)
Sets the name of a method to invoke on the target object.

Parameters

method
the name of the method to invoke

setResultId(String) Method

public void setResultId(String resultId)
Sets the identifier at which the result of invoking the method will stored.

Parameters

resultId
a String that names an attribute in the PageContext's attribute map where any resulting object will be stored.