jp.terasoluna.fw.web.struts.action
Class RequestProcessorEx

java.lang.Object
  extended by org.apache.struts.action.RequestProcessor
      extended by org.springframework.web.struts.DelegatingRequestProcessor
          extended by jp.terasoluna.fw.web.struts.action.RequestProcessorEx

public class RequestProcessorEx
extends org.springframework.web.struts.DelegatingRequestProcessor

Class extended from DelegatingRequestProcessor.

Receives the request from the client and invokes the action according to the URI. Following functions are added by inheriting org.springframework.web.struts.DelegatingRequestProcessor.

  1. Ensuring the uniqueness of the action form name starting with "_" in the session.
  2. When the logical name of action form in the session scope, starts with "_", all the other action forms which are stored in the session and which starts with the logical name as "_", are deleted at the time of creating the instance. This ensures that at the maximum only one action form is generated in the session and the memory can be utilized without any problem even if the source for the deletion process of action form under the session scope, is not written.

    Specification example of action form in struts-config.xml
     <struts-config>
     <form-beans>
     <!-- Attach "_" at the beginning of the form  -->
     <form-bean name="_sampleForm"
     type="jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormEx"
     >
     <form-property name="companyId" type="java.lang.String" />
          ...
     </struts-config>
     
  3. Feature that inhibits mapping of values in Form
  4. Skip processPopulate() when form is not switched from the action form in which business logic execution result is reflected.

  5. Retaining the action form error
  6. When there is input check error, store the action error in the action form to display the error on the pop up screen. When the error does not occur, set the empty action error in the action form.

  7. Log output function for the excpetion
  8. When the exception is thrown in the RequestProcessor#process(), output the exception stack trace to the log. After the log is output, exception is wrapped by the ServletException and is thrown.

To use RequestProcessorEx, it is necessary to perform the settings in the processorClass attribute of the <controller> element in struts-config.xml.

Configuration example of struts-config.xml
 <struts-config>
   ...
   <controller processorClass=
       "jp.terasoluna.fw.web.struts.RequestProcessorEx"/>
   ...
 </struts-config>
 
For the details of feature that inhibits the mapping values in Form, refer to the ActionEx.

See Also:
ActionEx, FormEx

Field Summary
private static org.apache.commons.logging.Log log
          Log class.
static java.lang.String SKIP_POPULATE
          Key when the flag which skips the processPopulate() is set in the request.
 
Fields inherited from class org.apache.struts.action.RequestProcessor
actions, INCLUDE_PATH_INFO, INCLUDE_SERVLET_PATH, moduleConfig, servlet
 
Constructor Summary
RequestProcessorEx()
           
 
Method Summary
 void process(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Extends the HTTP request process of Struts.
protected  org.apache.struts.action.ActionForm processActionForm(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, org.apache.struts.action.ActionMapping mapping)
          Extends the action form fetching process of Struts.
protected  org.apache.struts.action.ActionForm processActionFormEx(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, ActionMappingEx mapping)
          Extends the action form fetching process of Struts. It is invoked from processActionForm().
protected  void processPopulate(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
          Extends request parameter mapping process of the Struts action form.
 
Methods inherited from class org.springframework.web.struts.DelegatingRequestProcessor
determineActionBeanName, getDelegateAction, getWebApplicationContext, init, initWebApplicationContext, processActionCreate
 
Methods inherited from class org.apache.struts.action.RequestProcessor
destroy, doForward, doInclude, getInternal, getServletContext, internalModuleRelativeForward, internalModuleRelativeInclude, log, log, processActionPerform, processCachedMessages, processContent, processException, processForward, processForwardConfig, processInclude, processLocale, processMapping, processMultipart, processNoCache, processPath, processPreprocess, processRoles, processValidate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log class.


SKIP_POPULATE

public static final java.lang.String SKIP_POPULATE
Key when the flag that skips processPopulate() is set in the request.

See Also:
Constant Field Values
Constructor Detail

RequestProcessorEx

public RequestProcessorEx()
Method Detail

process

public void process(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws java.io.IOException,
                    javax.servlet.ServletException
Extends the HTTP request process of Struts.

This method catches the SystemException as well as the exception which is thrown by the process() method of ActionServlet in Struts. After the log is output, exception details and hash value of session ID are wrapped by the ServletException and are thrown.

Overrides:
process in class org.apache.struts.action.RequestProcessor
Parameters:
req - HTTP request
res - HTTP response
Throws:
java.io.IOException - IO exception
javax.servlet.ServletException - Servlet exception

processActionForm

protected org.apache.struts.action.ActionForm processActionForm(javax.servlet.http.HttpServletRequest req,
                                                                javax.servlet.http.HttpServletResponse res,
                                                                org.apache.struts.action.ActionMapping mapping)
Extends the action form fetching process of Struts.

Action forms specified in the action mapping and starting with the "_" are transferred to the processActionFormEx() for processing.

Overrides:
processActionForm in class org.apache.struts.action.RequestProcessor
Parameters:
req - HTTP request
res - HTTP response
mapping - Action mapping
Returns:
ActionForm Action form

processActionFormEx

protected org.apache.struts.action.ActionForm processActionFormEx(javax.servlet.http.HttpServletRequest req,
                                                                  javax.servlet.http.HttpServletResponse res,
                                                                  ActionMappingEx mapping)
Extends the action form fetching process of Struts. It is invoked from processActionForm().

Processes action forms which are specified in action mapping and starting with "_".

After performing the action form process, invokes processPopulate() method of RequestProcessor.

Parameters:
req - HTTP request
res - HTTP response
mapping - Action mapping
Returns:
Action form

processPopulate

protected void processPopulate(javax.servlet.http.HttpServletRequest req,
                               javax.servlet.http.HttpServletResponse res,
                               org.apache.struts.action.ActionForm form,
                               org.apache.struts.action.ActionMapping mapping)
                        throws javax.servlet.ServletException
Extends the request parameter mapping process of the Struts action form.

It invokes processPopulate() method of RequestProcessor when the form is switched from the action form in which business logic execution result is reflected, .

When the cancelPopulate is set to true in the action mapping settings of struts-config.xml, processPopulate is cancelled.

Overrides:
processPopulate in class org.apache.struts.action.RequestProcessor
Parameters:
req - HTTP request
res - HTTP response
form - Action form
mapping - Action mapping
Throws:
javax.servlet.ServletException - Servlet exception