0 Replies Latest reply on May 26, 2009 2:48 PM by cinconnu

    Get a result back from an asynchronous method

    cinconnu

      Hi,
      I'm trying to get a result back from an asynchronous method. But I looked into Seam code and understood that the Future returned by the interceptor is useless to me since it is using a Runnable and not a Callable...
      Maybe I'm taking the wrong path. My requirements are:



      • a modal popup (please wait) must be displayed while processing

      • the process should be cancelable ; the actual process itself is a remote service that cannot be canceled, but i need to hide the popup and continue working with my application

      • at the end of the process, hide the popup



      the problem here is that i cannot use a synchronous action since all subsequent queries will not be executed until the first one has returned (and then cannot cancel the action). Here what i'll trying to do without luck so far:



      1. call synch.start(), which calls aSynch.asynchProcess() -asynchronous- then return immediately

      2. display a please wait popup (as a result of a boolean flag set in the synch.start())

      3. polling with JS remoting, calling sth like synch.getResult()



      But i cannot pass the result from aSynch to synch, nor access the aSynch bean. I tried several things:



      • put bean in conversation or session scope ; only application scope is working

      • raise an asynchrounous event

      • returning a Future



      At the end I understood that asynchronous methods are kind of fire and forget. I looked here




      So is there any simple way to achieve that kind of things.
      Thanks


      David