Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by BaqHaidri:
http://wiki.apache.org/struts/StrutsPleaseWait

------------------------------------------------------------------------------
  === A plug & play solution to add a 'Please Wait' page to any Struts action 
===
  
- A while back I was tasked with providing 'please wait' functionality to the 
[http://panther.appliedbiosystems.com PANTHER] website. The requirement was 
that the solution be easily added to any action that the programmer felt needed 
it.  We already decided that using Javascript/CSS/hiding layers/etc. was not 
the right solution for us.  I thought to myself, given Struts' page flow 
flexibility and general extensibility, there's got to be a way to do this 
elegantly.  I couldn't really find anything on the web that showed a 
satisfactory solution.   When I finally came up with a solution, I was 
surprised that the Struts package didn't already come with a feature like it.  
+ A while back I was tasked with providing 'please wait' functionality to the 
[http://panther.appliedbiosystems.com PANTHER] website. The requirement was 
that the solution be easily added to any action that the programmer felt needed 
it.  We already decided that using Javascript/CSS/hiding layers/etc. was not 
the right solution for us.  I thought to myself, "Self, given Struts' page flow 
flexibility and general extensibility, there's got to be a way to do this 
elegantly".  I couldn't really find anything on the web that showed a 
satisfactory solution.   When I finally came up with a solution, I was 
surprised that the Struts package didn't already come with a feature like it.  
  
  The entire solution itself involves five elements:
  
@@ -32, +32 @@

  
  Ok, so now you have this attribute, {{{parameter="processWithWait"}}}.  What 
is Struts going to do with it?  As you may know, all incoming client requests 
go through the Struts {{{ActionServlet}}} then over to the Struts 
{{{RequestProcessor}}} class.  Depending on your configuration, this class then 
forwards to the appropriate Struts Action class for your actual business 
processing.  
  
- That's all nice and good.  But we don't want Struts to go right to our action 
just yet.  We want it to serve up our 'Please Wait' page first and then forward 
to our action.  That way, our user has a nice Please Wait page with some 
animation that they can swear at while our computers chug away in the 
background.  Here's where our overridden 
{{{RequestProcessor.processActionPerform}}} method comes in.  Now before you 
take a look at the lines and lines of code below (mostly comments), it's good 
to understand the following flow:
+ But we don't want Struts to go right to our action just yet.  We want it to 
serve up our 'Please Wait' page first and then forward to our action.  That 
way, our user has a nice Please Wait page with some animation that they can 
swear at while our computers chug away in the background.  Here's where our 
overridden {{{RequestProcessor.processActionPerform}}} method comes in.  Now 
before you take a look at the lines and lines of code below (mostly comments), 
it's good to understand the following flow:
  
   1. {{{RequestProcessor's}}} {{{processActionPerform}}} receives a request.
   2. It checks the action mapping to see if it's a long transaction.  If not, 
call {{{super.processActionPerform}}} and it's business as usual. 
@@ -159, +159 @@

              session.setAttribute("current_form_key", nonResetForm);
            } catch (Exception e) {
              System.out.println("*** Error cloning the form for 
processWithWait ***");
+             // Your error handling goes here.
            }
          }
          return mapping.findForward("pleaseWait");

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to