The proper way to solve this is to wait on the client. Only trigger
onSuccess after the first event has finished. It's hard to help much more
without a bit more info.

If that's not possible (I doubt) then you can wait serverside. The first
event could put an AtomicBoolean or CountDownLatch onto the session. This
is then looked up by the onSuccess event and waitForCompletion() called.
 On 12 Jul 2014 12:21, "Boris Horvat" <horvat.z.bo...@gmail.com> wrote:

> Hi everyone,
>
> I have a component that triggers the event, once the event is triggered, it
> will go to OnSuccess method that will try to refresh the zone as you can
> see below
>
>  private CaptureResultCallback<String> triggerEvent(Object value, Object[]
> context) {
>         CaptureResultCallback<String> callback = new
> CaptureResultCallback<String>();
>         List<Object> eventContext = new ArrayList<Object>();
>         if (context != null) {
>             eventContext.addAll(Arrays.asList(context));
>         }
>         eventContext.add(value);
>         this.resources.triggerEvent(UPDATE_EVENT, eventContext.toArray(),
> callback);
>         return callback;
>     }
>
>     Object onSuccess() {\
>         return request.isXHR() ? zoneFlowEdit.getBody() : null;
>     }
>
> However it can happen that this refresh it faster then processing of the
> event on the other side, so when the zone tries to refresh itself it doesnt
> have all of the information that it needs and it throws NPE.
>
> Is it possible to force the wait here so that I wait for the return of the
> callback and then proceed to the onSuccess method?
>
> Thanks
>
> --
> Sincerely
> *Boris Horvat*
>

Reply via email to