Through a recent debugging session I realized that when refreshing a "wait"
page during an ExecuteAndWait process, it calls the action's prepare() and
validate() methods each time. For some reason I thought Struts
would immediately identify the "waiting" Action, and if it wasn't finished,
it would return a WAIT result with the running Action at the top of the
stack.  I now realize since the ExecuteAndWait filter is at the end of the
interceptor stack, it obviously doesn't send the WAIT result until all
interceptors have been executed.

That said, in some of my long running actions the prepare() method hits the
database for some rather resource heavy database queries. So if I have an
executeAndWait page showing the progress status (refreshing every 2 seconds
in my case), this seems incredibly inefficient.  Is there a way to avoid
this?  Am I setting up my Action flow incorrectly?

A sample of one of my Action setups in struts.xml:

 <action name="ContactDelete"
class="com.afs.web.struts.action.contact.ContactDeleteAction">
            <interceptor-ref name="myParamsPrepareParamsStack" />
            <result>/struts/contact/contactDelete_modal.jsp</result>
            <result
name="error">/struts/common/error/error_modal.jsp</result>
            <result
name="login">/struts/common/login/login_modal.jsp</result>
</action>
<action name="ContactDelete_delete"
class="com.afs.web.struts.action.contact.ContactDeleteAction"
method="delete">
            <interceptor-ref name="myDefaultStack"/>
            <interceptor-ref name="openSessionExecuteAndWaitInterceptor" >
                <param name="delay">0</param>
            </interceptor-ref>
            <result
name="input">/struts/contact/contactDelete_modal.jsp</result>
            <result
name="wait">/struts/common/progressMonitorWait_modal.jsp</result>
            <result>/struts/common/progressMonitorSuccess_modal.jsp</result>
            <result
name="error">/struts/common/error/error_modal.jsp</result>
            <result
name="login">/struts/common/login/login_modal.jsp</result>
  </action>

Reply via email to