org.strutsme.server
Class StrutsMERequestProcessor

java.lang.Object
  extended by org.apache.struts.action.RequestProcessor
      extended by org.strutsme.server.StrutsMERequestProcessor
Direct Known Subclasses:
WishlistRequestProzessor

public abstract class StrutsMERequestProcessor
extends org.apache.struts.action.RequestProcessor

A special purpuse RequestProcessor which operates both with "normal" clients and with mobile clients.

For "normal" clients StrutsMERequestProcessor just calles the appropiate method of the super class. Only for StrutsME requests a special method is executed.

The distinction between a "normal" Http request and a StrutsME request is made basedon an additional Http parameter Constants.IS_STRUTSME_REQUEST which the StrutsME client sends.

The StrutsMERequestProcessor also supports transparent mapping from arbitary objects to DTOs (Data Transfer Objects) which extend SerializationBase. For this the user has to specify the package name which contains the classes. This is done using an init-param in the web.xml.

Example: the "normal" class is named "com.sun.Pet" and the package prefix is "com.sun.dto." (note the trailing dot) than StrutsMERequestProcessor will map this to "com.sun.dto.Pet".


Field Summary
 
Fields inherited from class org.apache.struts.action.RequestProcessor
actions, appConfig, INCLUDE_PATH_INFO, INCLUDE_SERVLET_PATH, log, moduleConfig, servlet
 
Constructor Summary
StrutsMERequestProcessor()
           
 
Method Summary
protected  SerializerMapper createMapper()
          Returns a SerializerMapper instance.
protected  void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           In the case of a classical request, this method only calls super.doForward.
 void init(org.apache.struts.action.ActionServlet actionServlet, org.apache.struts.config.ModuleConfig moduleConfiguration)
           Initialize this request processor instance.
protected  org.apache.struts.action.ActionForward processActionPerform(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.action.Action action, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
           Ask the specified Action instance to handle this request.
protected  void processForwardConfig(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.config.ForwardConfig forward)
           Forward or redirect to the specified destination, by the specified mechanism.
protected  void processPopulate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
           Populate the properties of the specified ActionForm instance from the request parameters included with this request.
protected  boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
          
 
Methods inherited from class org.apache.struts.action.RequestProcessor
destroy, doInclude, getDebug, getInternal, getServletContext, internalModuleRelativeForward, internalModuleRelativeInclude, log, log, process, processActionCreate, processActionForm, processActionForward, processContent, processException, processForward, processInclude, processLocale, processMapping, processMultipart, processNoCache, processPath, processPreprocess, processRoles
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrutsMERequestProcessor

public StrutsMERequestProcessor()
Method Detail

init

public void init(org.apache.struts.action.ActionServlet actionServlet,
                 org.apache.struts.config.ModuleConfig moduleConfiguration)
          throws javax.servlet.ServletException

Initialize this request processor instance.

Overrides:
init in class org.apache.struts.action.RequestProcessor
Parameters:
actionServlet - The ActionServlet we are associated with
moduleConfiguration - The ModuleConfig we are associated with.
Throws:
javax.servlet.ServletException - If an error occor during initialization

processForwardConfig

protected void processForwardConfig(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    org.apache.struts.config.ForwardConfig forward)
                             throws java.io.IOException,
                                    javax.servlet.ServletException

Forward or redirect to the specified destination, by the specified mechanism. This method uses a ForwardConfig object instead an ActionForward.

todo: provide way of configuring the extension.

Overrides:
processForwardConfig in class org.apache.struts.action.RequestProcessor
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
forward - The ForwardConfig controlling where we go next
Throws:
java.io.IOException - if an input/output error occurs
javax.servlet.ServletException - if a servlet exception occurs

doForward

protected void doForward(java.lang.String uri,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.io.IOException,
                         javax.servlet.ServletException
In the case of a classical request, this method only calls super.doForward. If the request comes from an StrutsME-Client, the result of the formvalidation is checked. If the validation has failed, the original formdata and the generated messages are written to the response and no forward is performed. If the validation was successfull, only super.doForward is called.

Overrides:
doForward in class org.apache.struts.action.RequestProcessor
Throws:
java.io.IOException
javax.servlet.ServletException

processActionPerform

protected final org.apache.struts.action.ActionForward processActionPerform(javax.servlet.http.HttpServletRequest request,
                                                                            javax.servlet.http.HttpServletResponse response,
                                                                            org.apache.struts.action.Action action,
                                                                            org.apache.struts.action.ActionForm form,
                                                                            org.apache.struts.action.ActionMapping mapping)
                                                                     throws java.io.IOException,
                                                                            javax.servlet.ServletException

Ask the specified Action instance to handle this request. Return the ActionForward instance (if any) returned by the called Action for further processing.

Overrides:
processActionPerform in class org.apache.struts.action.RequestProcessor
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
action - The Action instance to be used
form - The ActionForm instance to pass to this Action
mapping - The ActionMapping instance to pass to this Action
Returns:
the forward
Throws:
java.io.IOException - if an input/output error occurs
javax.servlet.ServletException - if a servlet exception occurs

processPopulate

protected final void processPopulate(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     org.apache.struts.action.ActionForm form,
                                     org.apache.struts.action.ActionMapping mapping)
                              throws javax.servlet.ServletException

Populate the properties of the specified ActionForm instance from the request parameters included with this request. In addition, request attribute Globals.CANCEL_KEY will be set if the request was submitted with a button created by CancelTag.

Overrides:
processPopulate in class org.apache.struts.action.RequestProcessor
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
form - The ActionForm instance we are populating
mapping - The ActionMapping we are using
Throws:
javax.servlet.ServletException - if thrown by RequestUtils.populate()

createMapper

protected SerializerMapper createMapper()
                                 throws javax.servlet.ServletException
Returns a SerializerMapper instance. This method can be overwritten.

Returns:
the SerializerMapper
Throws:
javax.servlet.ServletException - if the packagePrefix wasn't configured

processValidate

protected boolean processValidate(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response,
                                  org.apache.struts.action.ActionForm form,
                                  org.apache.struts.action.ActionMapping mapping)
                           throws java.io.IOException,
                                  javax.servlet.ServletException,
                                  org.apache.struts.action.InvalidCancelException

Overrides:
processValidate in class org.apache.struts.action.RequestProcessor
Throws:
java.io.IOException
javax.servlet.ServletException
org.apache.struts.action.InvalidCancelException