BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

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

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.databinding.invoke.AbstractCallMethod
All Implemented Interfaces:
HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
CallControl, CallMethod

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 MethodParamter#setType() 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.

See Also:
Serialized Form

Nested Class Summary
protected static class AbstractCallMethod.ParamNode
          An internal struct that represents a parameter that will be passed to a reflective method invocation call.
 
Field Summary
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
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
AbstractCallMethod()
           
 
Method Summary
 void addParameter(String type, Object parameter)
          Add a paramter that will be passed as an argument to the method that will be invoked.
 int doEndTag()
          Reflectively invokes the method specified by the method attribute, getMethod().
 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
 boolean getFailOnError()
          Get whether or not errors invoking a method are reported in-line when the tag renders.
 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.
 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.
 void setFailOnError(boolean failOnError)
          Sets whether or not to report exceptions to the page when errors occur invoking a method on an object.
 void setMethod(String method)
          Sets the name of a method to invoke on the target object.
 void setResultId(String resultId)
          Sets the identifier at which the result of invoking the method will stored.
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, filter, formatErrorString, formatString, getAttribute, getErrorsReport, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getTagName, getUserLocale, hasErrors, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, reportErrors, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setParent
 

Constructor Detail

AbstractCallMethod

public AbstractCallMethod()
Method Detail

resolveObject

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.
Throws:
ObjectNotFoundException - if an exception occurred attempting to resolve an object

getObjectName

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.

handleReturnValue

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 getResultId() String is not null. If the value returned from calling a method is null and the getResultId() is non-null, the javax.servlet.jsp.Pagecontext#removeAttribute(java.lang.String) is called to remove the attribute from the attribute map.

Parameters:
result - the object that was returned by calling the method on the object

getParameterNodes

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

setResultId

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.
Beadoc.attributedescription:
The data returned by the method is loaded into the PageContext object, under this property name.
Beadoc.attributesyntaxvalue:
string_resultId
Beadoc.databindable:
false

getResultId

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.

setFailOnError

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.
Beadoc.attributedescription:
Boolean. If set to true, any errors occuring while invoking the control method will be be reported in-line on the JSP page.
Beadoc.attributesyntaxvalue:
boolean_failOnError
Beadoc.databindable:
false

getFailOnError

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.

setMethod

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
Beadoc.attributedescription:
The name of the method to invoke
Beadoc.attributesyntaxvalue:
string_method
Beadoc.databindable:
false

getMethod

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

Returns:
the name of the method to invoke

addParameter

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
See Also:
MethodParameter

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.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.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_BUFFERED
Throws:
javax.servlet.jsp.JspException
See Also:
MethodParameter

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Reflectively invokes the method specified by the method attribute, 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(java.lang.String, java.lang.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 handleReturnValue(java.lang.Object).

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_PAGE to continue evaluating the page
Throws:
javax.servlet.jsp.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.
See Also:
getMethod(), handleReturnValue(java.lang.Object), MethodParameter, ObjectNotFoundException, TypeUtils.convertToObject(java.lang.String, java.lang.Class), String

localRelease

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

Overrides:
localRelease in class AbstractBaseTag

findMethod

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.

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.