czw., 7 paź 2021 o 16:16 Burton Rhodes <burtonrho...@gmail.com> napisał(a):
>
> 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>

prepare() and validate() are called by different interceptors, which
means you must put your Exec&Wait interceptor before them in the
stack. I would use a custom stack for Exec&Wait actions with proper
order of interceptors. As I see you have a default stack which is
prepended to Exec&Wait interceptor and that's why those methods are
called.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to