Hi Sebastian,
If you intend to use Wicket's default detachable models to get data from
those services, they will be called sequentially. So those are out. I
see 2 options:
- In the panel constructor get the data in parallel threads through
standard java 5 constructs (dump all your Callables in a ExecutorService
and when that is done call get() on the returned Futures). When you have
the data continue as normal. This approach is a bit easier then the next
option, but only works with stateless pages (unless you known the data
is not going to change soon anyway).
- Write your own model (extend LoadableDetachableModel) that in the
constructor will start a new thread to get the data (put a Callable in
an ExecutorService and store the Future). Method load() should block
until the thread is done (simply call get() on the Future). The base
class will clear the data upon detach. Unfortunately, there is no
onAttach() method that Wicket calls when the model data is needed again.
To remedy this, you could call an onAttach() method yourself from
onBeforeRender() in the component that uses the model. The onAttach
method should do nothing when the data is already there, or a Future is
already present (which means the data is already being retrieved).
(I assume you have read a book on concurrency. If not you should, for
example "Java Threads".)
Regards,
Erik.
Sebastian wrote:
Hi,
I have not yet looked much into Wicket but am quite interested in the
project.
We have a specific requirement where I could not yet find the right
information/documentation for.
We need to put multiple components onto a page receiving data through
web services. A single web services call takes some time. In our
scenario it would be bad to have the different components of a page to
request their data sequentially, therefore we'd like to have
components retrieve the required data in parallel by firing the web
services call concurrenlty.
What is the best approach to achieve this (preferable in a generic,
reusable fashion).
I do not want to use AJAX for this, the whole page needs to be
rendered at once on the server side.
Thanks for any hints and thoughts in advance,
Seb
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]