Hi,

Both are similar.

@WaitPage annotation tries to simplify things for you by masking a lot of 
things you would need to code yourself.
One example is that the action bean with all parameters may not be available in 
Remi’s code, unless the Runnable has access to it.

One advantage of Remi’s code is that it’s clear that you are starting a long 
process and you don’t want to force your user to wait for it.
With @WaitPage, the annotation is the only thing that allows you to know this 
method will take a long time. Even worse, if you forget to register the 
WaitPageInterceptor and a user calls the annotated method, he will believe the 
page doesn’t respond…

Christian


De : Joaquin Valdez <joaquinfval...@gmail.com<mailto:joaquinfval...@gmail.com>>
Répondre à : Stripes Users List 
<stripes-users@lists.sourceforge.net<mailto:stripes-users@lists.sourceforge.net>>
Date : Saturday, January 23, 2016 at 1:41 PM
À : "r...@rvkb.com<mailto:r...@rvkb.com>" 
<r...@rvkb.com<mailto:r...@rvkb.com>>, Stripes Users List 
<stripes-users@lists.sourceforge.net<mailto:stripes-users@lists.sourceforge.net>>
Objet : Re: [Stripes-users] Writing to response.writer is not working

Hi!

Is this the same idea as this:

https://stripesframework.atlassian.net/wiki/display/STRIPES/Wait+Page+for+Long+Events
 ?

Joaquin

On Jan 23, 2016, at 10:52 AM, VANKEISBELCK Remi 
<r...@rvkb.com<mailto:r...@rvkb.com>> wrote:

Hi again,

Seems like a regular "long running job / polling" scenario. It can be done with 
current Stripes version, even if it will be less performant if your http client 
is really non blocking, but that's another story.

So here's how I'd do this.

1/ Server side

In the ActionBean, I'd submit a task to an executor service (a thread pool) 
with that long running job that calls the webservice. This task should update 
the back-end state in some way, so that you can do polling and know when it's 
done.
The same ActionBean can handle Ajax polling via another event method. This one 
will be called from some JS code in your page.

public class MyAction implements ActionBean {

  public Resolution triggerLongRunningJob() {
    // retrieve Executor Service, from servlet context or custom 
ActionBeanContext
    ExecutorService executorService = ... ;
    // submit task
    executorService.submit(new MyLongRunningTask(...);
    // return a redirect resolution to the "wait" screen
    return new RedirectResolution(getClass(), "displayWaitScreen")
  }

  public Resolution displayWaitScreen() {
    return new ForwardResolution("/WEB-INF/jsp/wait-screen.jsp");
  }

  public Resolution poll() {
    // find task completion status and return to the client
    String jsonTaskCompletion = ... ;
    return new StreamingResolution("application/json", jsonTaskCompletion);
  }


  // the long running task code is in a Runnable
  private class MyLongRunningTask implements Runnable {
    public void run() {
      // call the webservice and update internal state

    }
  }
}


2/ Client side

First you'll submit the form to the 'triggerLongRunningJob' event. This will 
launch the background task and return directly.
Then, you'll send xhr requests to the 'poll' event, that will tell you what to 
do next. If task has completed, then you'll probably change the location of the 
browser in some way in order to display a "result" page of some sort (ie use 
your data from the completed task and do whatever you need with it).

HTH

Rémi





2016-01-23 17:05 GMT+01:00 Ron King 
<ronck...@gmail.com<mailto:ronck...@gmail.com>>:
Hi everyone,

I want to write an html page back to the user at the very beginning of an 
ActionBean submit method.
The method calls a web service that takes around a minute to respond, and I 
want to put up a message
before the web service finishes.

I'm on Tomcat 8. I tried flushing the writer, but the page still doesn't 
display until after I return the
Resolution from the submit method.

Is there a way to make it write immediately?

Regards,

Ron

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to