Glad you got to a solution, Erik,

Cheers
Dan

On 7 April 2015 at 10:31, Erik de Hair <[email protected]> wrote:

>
> On 04/03/2015 09:03 AM, Erik de Hair wrote:
>
>>
>>
>>> Then the question is how to hold that server-side state.  An HTTP Session
>>> object is one option; the other is to store the data in the database.
>>> That
>>> basically means converting the view model into an entity (analogous to a
>>> shopping cart entity); you could have some mechanism to clean up such
>>> session entities after a day or two.
>>>
>> My architecture didn't work correctly. I tried to put the data in the
> memento as json-object but this way the memento got to big, and this gives
> persisting problems for the auditing/publishing services. Right now I'm
> putting the same data in the HTTP session and this works as it should be.
>
> Thanks for your help,
> Erik
>
>
>
>>> Hope that helps provide some ideas...
>>>
>>> Cheers
>>> Dan
>>>
>>>  Hi Dan,
>>
>> Thanks for your ideas. In the meantime I was changing the architecture of
>> the view model calling the web service. I let the web service return a json
>> string of al data to be returned and populate the datatables in the view
>> model by reconstructing view models based on this json string contained in
>> the view model memento.
>>
>> The web service will now only be called by the action asking for web
>> service parameters.
>>
>> Erik
>>
>>>
>>> On 1 April 2015 at 11:33, Erik de Hair <[email protected]> wrote:
>>>
>>>  On 03/27/2015 12:26 PM, Dan Haywood wrote:
>>>>
>>>>  Hi Erik,
>>>>>
>>>>> On 25 March 2015 at 12:42, Erik de Hair <[email protected]> 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?
>>>>>
>>>>>  The following is happening...
>>>>
>>>> In the initial state the view model is rendered and the data that is
>>>> needed to call the web service is already available from the view model
>>>> memento. (This means that when refreshing the page the web service will
>>>> be
>>>> called again. This is not much of a problem.)
>>>>
>>>> Now, when clicking** the action button that opens the action for
>>>> re-entering the web service parameters, a request for the view model is
>>>> done:
>>>>
>>>> 0:0:0:0:0:0:0:1 - - [01/Apr/2015:12:04:09 +0200] "GET
>>>> /portal/wicket/entity/*nl.pocos.dom.access.availability.PostalCodeCheck:
>>>>
>>>> PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG1lbWVudG8-PGpzb24-
>>>>
>>>> eyJwb3N0YWxDb2RlIjoiNTYxNEFFIiwiaG91c2VOdW1iZXIiOiIxNTIifTwv
>>>> anNvbj48L21lbWVudG8-?6-1.IBehaviorListener.0-theme-entity-entity~0-
>>>> entityPropertiesAndCollections-entityProperties-leftColumn-
>>>> memberGroup-1-properties-4-property-scalarIfRegular-additionalLinks-
>>>> additionalLinkList-additionalLinkItem-0-additionalLink&_=1427882228283
>>>> HTTP/1.1" 200 12838 http-bio-8081-exec-4 2303
>>>>
>>>> This way the web service is called again because the previous web
>>>> service
>>>> parameters are still available from the view model memento.
>>>>
>>>> After submitting the following requests are handled:
>>>>
>>>> 0:0:0:0:0:0:0:1 - - [01/Apr/2015:12:06:17 +0200] "POST
>>>> /portal/wicket/entity/*nl.pocos.dom.access.availability.PostalCodeCheck:
>>>>
>>>> PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG1lbWVudG8-PGpzb24-
>>>>
>>>> eyJwb3N0YWxDb2RlIjoiNTYxNEFFIiwiaG91c2VOdW1iZXIiOiIxNTIifTwv
>>>> anNvbj48L21lbWVudG8-?6-1.IBehaviorListener.1-theme-
>>>> actionPromptModalWindow-content-parameters-inputForm-okButton HTTP/1.1"
>>>> 200 91 http-bio-8081-exec-6 169
>>>>
>>>> (web service called two times during this request)
>>>>
>>>> 0:0:0:0:0:0:0:1 - - [01/Apr/2015:12:06:19 +0200] "GET
>>>> /portal/wicket/wicket/page?7 HTTP/1.1" 200 167629 http-bio-8081-exec-6
>>>> 2582
>>>>
>>>> (web service called once during this request)
>>>>
>>>>  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.
>>>>>
>>>>>  I tried this but the method that exposes the data to the gui will
>>>> always
>>>> call the method that fetches the data when constructing the view model.
>>>> So
>>>> no matter how late the data will be fetched, it will always be fetched.
>>>>
>>>>  Another option might be to have the view model use the HttpSession (via
>>>>> isis-module-servletapi addon) to keep track of state.
>>>>>
>>>>>  I'm still using Isis 1.7.0 and Eclipse complains about the module
>>>> missing
>>>> some dependency. It does work however and I can prevent the web service
>>>> from being called by checking for a request method of GET during the
>>>> POST-request but there are still 3 calls left.
>>>>
>>>> I didn't use the session object yet. Will try that.
>>>>
>>>>
>>>>  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
>>>>>>
>>>>>>
>>>>>>
>>
>

Reply via email to