com.iplanet.jato
Interface RequestHandler

All Superinterfaces:
RequestParticipant
All Known Subinterfaces:
ViewBean
All Known Implementing Classes:
RequestHandlingViewBase, RequestHandlingTiledViewBase

public interface RequestHandler
extends RequestParticipant

A request handler is a view that can handle a request that pertains to it. In the JATO foundation claases, POSTs or GETs from the client are routed back to the view bean that generated the original page. This preserves client-server event-like semantics for request invocations. However, the request is not routed only to the view bean, but to the contained view that contains the button or href that was pressed. Thus views can be nested arbitrarily and still act independently of their container. Furthermore, container views need not understand or even know that contained subviews are generating buttons or hrefs that can be chosen by the user. This provides a great deal of modularity.

For example, a particular view may contain a number of buttons and be embedded in another view (a tiled view with buttons on each row, contained within a view bean). A press of one of the buttons originally displayed by this subview should result in a request "event" back to the same view, not the containing view bean, which wouldn't know how to handle the request without intimate (and undesirable) knowledge of its contained views.

Version:
JATO/1.2.2 $Id: RequestHandler.java,v 1.5 2002/03/16 03:26:28 todd Exp $

Method Summary
 java.lang.Object acceptRequest(javax.servlet.http.HttpServletRequest request)
          This method is used by the application servlet to determine if this is the appropriate view to handle the servlet request.
 RequestContext getRequestContext()
          Returns the current request context
 void handleRequest(java.lang.Object invocation)
          Called by the application servlet to have the request handler process this request.
 
Methods inherited from interface com.iplanet.jato.RequestParticipant
setRequestContext
 

Method Detail

getRequestContext

public RequestContext getRequestContext()
Returns the current request context
Returns:
The request context for the current servlet request

acceptRequest

public java.lang.Object acceptRequest(javax.servlet.http.HttpServletRequest request)
This method is used by the application servlet to determine if this is the appropriate view to handle the servlet request. The view should determine if one of its CommandField display fields generated this request, and return an invocation object describing the invocation.
Parameters:
request - The current servlet Request object
Returns:
An opaque invocation object that encapsulates information about the request which the handleRequest(...) method will later need, or null if this object cannot handle this request. Note that the application servlet does not use the information encapsulated in the invocation object, but rather calls the handleRequest(...) method on this same object and passes in the invocation object returned by this method.

handleRequest

public void handleRequest(java.lang.Object invocation)
                   throws java.lang.Exception
Called by the application servlet to have the request handler process this request. In the base implementation of JATO, this method will further dispatch the request to a handler method of a specific signature, depending on the view. See the derived class's documentation for information on the appropriate method signature to use. Thus, there is no need to override this method in implementing classes, though of course, there is no reason one could not. Such a technique may be well suited to single-location security handling, logging, or other tasks. Or, developers could override this method to handle the request in much the same way they might in a servlet. This technique is generally discouraged, however, because of the cumbersome implementation it would require. The expected behavior of the handling method (or this method, if totally overridden) is to forward the request to another JSP/view bean, preparing the target in any way necessary to support the request. Note that the current request context has already been set when this method is called by virtue of the RequestParticipant interface, from which this interface derives.
Parameters:
invocation - The opaque invocation object previously returned by the acceptRequest(...) method. The implementation can store any information useful to it in this object.