isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Haywood <...@haywood-associates.co.uk>
Subject Re: calling webservice only once from viewmodel
Date Fri, 27 Mar 2015 11:26:06 GMT
Hi Erik,

On 25 March 2015 at 12:42, Erik de Hair <e.dehair@pocos.nl> wrote:

> Hi,
>
> I have to call I web service from a view model but, when opening the view
> model, the call to the web service is called twice. It doesn't matter if
> the call is in de viewmodelinit or in some other method. May be there's
> some way to track the state of the view model and let whether or not the
> call is executed depend on that?
>

My guess is that you are seeing the view model called twice because we use
(Wicket's support for) the redirect-after-post pattern.

That is, when the action is invoked you are instantiating the view model
(which calls the webservice), and then we return a 302 redirect to the
browser so that it then re-requests the same URL, causing the view model to
be recreated (and that webservice called).

Perhaps you could confirm if that's what's happening?

If it is, then one option might be to defer the fetching of the data until
as late as possible, ie when it needs to be constructed.

Another option might be to have the view model use the HttpSession (via
isis-module-servletapi addon) to keep track of state.

HTH
Dan



>
> The web service is fetching data, triggered by an action in the view
> model, for the same view model. Do I always have to return a new view model
> with the fetched data in it or can I use the data from the fetch method and
> return the same view model?
>
> Thanks,
> Erik
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message