com.taggercat.handlers
Class ExecuteMethodRequestHandler

java.lang.Object
  extended by com.taggercat.handlers.AbstractRequestHandler
      extended by com.taggercat.handlers.ExecuteMethodRequestHandler
All Implemented Interfaces:
com.taggercat.el.ELPropertyResolver, RequestHandler

public class ExecuteMethodRequestHandler
extends AbstractRequestHandler

This request handler is used to execute a method on a scope accessible object, A.K.A. an Action or Managed Bean. You can use this request handler to call methods on objects rather than always needing to create a custom request handler.

The method to execute can simply be set with the actionName parameter, or optionally a request parameter named executeMethodName:

The dot delimited name can optionally be prefixed with a scope identifier. The supported explicit scope identifiers are:

Example method names

Example 1: sessionScope.CustomerBean.primaryContact.notify

Processing Steps:

  1. locate an object named "CustomerBean" on the session scope
  2. since a sub-object is specified, call getPrimaryContact() on the located CustomerBean object
  3. call the notify( HttpServletRequest, HttpServletResponse ) or the notify() method on the PrimaryContact object

Calls to nested sub-objects can be to any level. For example"CustomerBean.orders.accounts.currentAccount.update.

Example 2: CustomerBean.primaryContact.notify

Processing Steps:

  1. locate an object named "CustomerBean" on one of the scope objects specified above, searching in the order listed
  2. since a sub-object is specified, call getPrimaryContact() on the located CustomerBean object
  3. call the notify( HttpServletRequest, HttpServletResponse ) or the notify() method on the PrimaryContact object

Example 3: CustomerBean.processOrder

Processing Steps:

  1. locate an object named "CustomerBean" on one of the scope objects specified above, searching in the order listed
  2. call the processOrder( HttpServletRequest, HttpServletResponse ) or the processOrder() method on the PrimaryContact object

The called method must meet the following requirements:

  1. accepts both a HttpServletRequest and HttpServletResponse arguments , or takes no arguments
  2. return a String object with a value of either "success" or an error message.

If the method signature accepting the HttpServletRequest and HttpServletResponse parameters is found, then that method is called with the current request and response objects. Otherwise, the no argument version is called. If the method returns "success" then the request has completed without error, and the response page is issued, or the next request handler in the request handler chain is called. Otherwise, the request has failed, and the error page is issued.

 

Constructor Summary
ExecuteMethodRequestHandler()
           
 
Method Summary
 java.lang.String executeMethod(java.lang.Object startingObject, java.lang.String scopedMethodName)
          Executes the named method.
 
Methods inherited from class com.taggercat.handlers.AbstractRequestHandler
disableClientCache, getDataSourceName, getErrorException, getErrorPage, getErrorPageMethod, getErrorReason, getExplicitDataSourceName, getExplicitDSN, getMatchedPattern, getModel, getRequestController, getResponsePage, getResponsePageMethod, getSessionExpiredPage, getUserName4Log, init, isAjaxRequest, onChainCompleted, resolveProperty, serverTemporaryFile, serveTemporaryFile, service, setActionName, setErrorPage, setErrorPageMethod, setErrorPageMethodToRedirect, setExplicitDataSourceName, setExplicitDSN, setMatchedPattern, setResponsePage, setResponsePageMethod, setResponsePageMethodToRedirect, setSessionExpiredPage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecuteMethodRequestHandler

public ExecuteMethodRequestHandler()
Method Detail

executeMethod

public java.lang.String executeMethod(java.lang.Object startingObject,
                                      java.lang.String scopedMethodName)
                               throws javax.servlet.ServletException
Executes the named method.

Throws:
javax.servlet.ServletException
Parameters:
startingObject - the source, or starting object to execute the method on
scopedMethodName - the name of the scoped method of the form = "sessionScope.Test9.test8.test7.foo";
Returns:
a string result, "success" if the method completed without error