-
1. Re: Raising Events from @Async... method
lvdberg Mar 30, 2011 3:20 PM (in response to getboa)Hi,
make it a chain where you place the observer in another bean (that's what I usually do) In any way the method is called async and the call will NOT use the same bean (-instance) it will make a new instance when the event is raised.
Leo
-
2. Re: Raising Events from @Async... method
getboa Mar 31, 2011 11:56 AM (in response to getboa)
Leo van den Berg wrote on Mar 30, 2011 15:20:
Hi,
make it a chain where you place the observer in another bean (that's what I usually do) In any way the method is called async and the call will NOT use the same bean (-instance) it will make a new instance when the event is raised.
LeoHi Leo,
thanks for your reply. Could you please explain it a little bit more!? -
3. Re: Raising Events from @Async... method
getboa Mar 31, 2011 8:56 PM (in response to getboa)Did you mean to create a sort of @Filter and place that @observer in there?
Sorry I didn't get it properly. -
4. Re: Raising Events from @Async... method
lvdberg Apr 1, 2011 2:50 AM (in response to getboa)Hi,
I mean that you should create a third bean which handles the termination of the long-running task.
So:
(1) Start the process with callerAsync.runAsyncMethod();
(2) The observing callerAsync handles this request through its observer, and
(3) A third beanresultObserver
handles the event after processing the whole task.Although it looks this way, if your
first bean
(which kicks-off the task) isn't an application scoped bean, the Asynchronity of the different calls will not reach the calling bean, You could consioder making the fist bean application scoped, but that will be tricky when you're with these kind of unpredictable threads and especially if several users can start such an event.If you just want to store the result in a database, the chain of observers with an event scope will work fine if you add a createtrue attribute to you observer.
Leo
P.S. Although the static call works fine, i prefer to inject the Events component with a standard in-aanotation.
.
-
5. Re: Raising Events from @Async... method
getboa Apr 5, 2011 8:01 AM (in response to getboa)Hi Leo,
Thanks a lot.
It worked, but I'm getting a weird behaviour on the progressBar from richfaces framework, What I'm doing is, the user provides an amount of objects to be loaded from database, afterwards the application validates those objects and that's it. It supposed now to show the user, a facesmessage with the result of this process(success or fail), which is in
f:facet namecomplete
. The problem is, if the user provides an amount like, over than 100, the f:facet namecomplete
is not reached, but if it's less than 100 it works like a charm.
Do you have any idea of why it's behaving like that? -
6. Re: Raising Events from @Async... method
lvdberg Apr 5, 2011 8:09 AM (in response to getboa)Hi,
I included a code snippet of one of our applications. The checkProgress method provides a value between 0 and 100%
You must change the max and min-value for other ranges.
<rich:progressBar label="#{bean.instance.checkProgress()} %" eventsQueue="inputQueue" ajaxSingle="true" interval="10000" id="progressHandling" value="#{bean.instance.checkProgress()}" minValue="-1" maxValue="100"/>
Leo