Page 1 of 1

Next action runs before the REST call is fully processed / local storage empty after a REST call

Posted: Thu Jul 31, 2014 3:42 am
by Alexis Revue

Hi,

Something weird happens with the actions of an onclick event.

Basically, I have 2 pages:
1_Form with some inputs and a submit button
2_Synthesis with a label.

When I click on the button, I call a REST service with the inputs and I would like to display the result (just a string variable) on the second page.

So, on the first page, I call the REST service and bind the output data to a local storage variable. Then I am supposed to be able to display that storage variable on the second page.
To do so, the "onclick" event of my button has 2 actions:

  • invoke REST Service, binding the output to a local storage variable.

  • Navigate to page 2

    However, it doesn't work: the local storage variable is empty on the 2nd page.
    It seems like the 2nd action (navigate) starts after the REST is invoked but before the storage variable is bound.

    Indeed, if in datasource, I add an alert "A" when I assign the response to the storage variable, and if I add a JS action (alert "B") between "Invoke REST" and "Navigate to page 2", then, "B" pops up before "A", meaning that the actions after "invoke Rest" run although the response hasn't been processed and saved in storage variables.

    I don't think it should be the expected result, could you confirm?

    How can I solve the problem?

  • Page 1 with inputs

  • Call a REST service with these inputs

  • Display the results on the second page.
    As explained before, it looks like there is an issue if I invoke the service before leaving the first page.

    NB: the REST service is OK, when I add "alert(value)" in JS in the datasource, the value is correct...


Next action runs before the REST call is fully processed / local storage empty after a REST call

Posted: Thu Jul 31, 2014 7:28 am
by Evgene Karachevtsev

Hello Alexis,

You should add to Navigate to page 2 action on success of the event service


Next action runs before the REST call is fully processed / local storage empty after a REST call

Posted: Sun Aug 03, 2014 12:16 am
by Alexis Revue

Hello Evgene,

How do I have to do this? Is it in the Event panel (Component/Event/Action) ?


Next action runs before the REST call is fully processed / local storage empty after a REST call

Posted: Sun Aug 03, 2014 3:27 am
by Alena Prykhodko

Hi Alex,

On page Data tab- Events.


Next action runs before the REST call is fully processed / local storage empty after a REST call

Posted: Sun Aug 03, 2014 3:35 am
by Alexis Revue

Hi Alena,

Now I see it, thank you very much Evgene and Alena ! :)