Refresh a page automatically after the end of the execution of a timer

Refresh a page automatically after the end of the execution of a timer

Good morning.

I need to refresh a page automatically after the end of the execution of a timer. i have a page that need to synchronize data with a call to a web service, and this take a lot of time to response. So i have done a timer so the page doesn't stay waiting for the response from the web service, and the user can consult the page normally. But i need to refresh my LIST at the end of the timer.

Any bright idea: p

erm ajax? :P

Best way I know now would be to have a hidden button in the page which call's a action that (ajax) refresh the list.

In the preparation of the screen you set the button's id to a session variable. When the timer is done you can use the action: widget_click (richWidgets) where the widgetid is the session variables that holds the button id.

When you timer is ready it will click the hidden button which refresh your List.

Kind Regards,
how ?

i have made a function that tell me if the timer is running..

i have made a function in JavaScript that call my function to check if the timer is running or not. but the page is allways refreshing...   

but when i call the timer  (" Wake_TIMERNAME" ) i lose the control of the event..... the page load normally...  right?

If i'm correct the timer is set to an action? So the timer is finished when this action is done?

In the action that the timer calls you set the widget_click funtion (as action before the end) to click the hidden button, this button will then refresh the list in that screen.

Kind regards,
sorry to poke into the discussion, but why not make a async-call to the webservice?

you don't need a timer but just continue until the function you provided is called (aka service responded)

Ye you are right.. But the action doesn't recognise the WidgetID... i will try a input parameter, in the action,  with the default Value "refresh.Id"


In the preparation of the screen you'll use an assign to set the '" to a session variable

When you use the widget_click you need to set session variable as the inputWidgetId.

Kind Regards,
The session value Is empty inside the action... :(
How long does the action take?

The default session time is 20 minutes...

Do you assign the id right? (debug preparation of the screen to see if the id of the hidden button is been set to the session var).

Mayby it's something else:

The button, how do you hide it? By the OS Boolean? Because that's not working, you need to set a extended property: style, with value: display: none;.

Kind Regards,
the timer take 3min .

i have hidden the button by CSS Style - "display:none" otherwise the html inst generated to the screen..

in debug mode  the session.Widget as the but when i enter in the Action all the session vars are empty...... includind Session.UserID
That shouldn't suppose to happen....the session vars are filled before entering the action?

Else I would say send it to support to find out why the session vars are empty.

Kind Regards,
yes.., i have values in the session var before entering on the actions.
Good morning,

I created a lookup table that contains the ID of the widget, but anyway
WIDGET_CLICK not working ...

can you share the espace / page?

because I have the feeling it's pretty simple what you want to achieve,
yet with all the discussion it's rather complex what you are making.

why don't you call the webservice async in the page, continue as expected, and when the webservice returns you execute the refresh-button?
you don't have to worry about a timer (which is bad imho) then.

I want to quote only that the webservice is being consumed by an action developed in the integration studio , which returns an xml and then fill out the structure of my data with XMLtoRecordList.
Hello Joost Landgraf, you can send an example of your solution
Hi all,

Let me add my 50 cents to the discussion.

1 - Using a timer as described is wrong. Timer in OutSystems platform run in separate processes therefore the session is not the same as the one for the HTTP request, this is why your session variable is empty. Since it runs in a separate process it has no access to the HTTP context of the first request and so using Widget_Click would never work.

2 - Using an ajax call - this seems to be the right approach, as Joost mentioned. In your page you'll have a button that triggers an action using ajax. after your webservice response (either directly or via extension call) and response processing you'll need to use the ajax refresh widget to refresh the necessary parts on your webpage.

Hope this is helpful to all.
Hello André,

Thanks for the addition of point one, didn't thought about that (shame on me).

Hope the second answer is also the solution for Bruno.

Kind regards,
I understand what you are trying to say, the problem is i cannot stay with the page blocked 10 minutes awaiting response from the WebService ... 
I'm using the timer because  is already developed and runs everyday overnight .. so if i wake the timer i can still browsing the page. 
what i need  is something that permits  me to synchronize the data at present and continue browsing the page and when the synchronization finish automatically update the page 
Hi Bruno,

If your timer takes that long you can try to add some javascript to periodically refresh the page.
When you press the button that wakes the timer you refresh a container on the page with an unescaped expression with a javascript something like
setTimeout(function() { document.getElementById('" + LinkToRefreshPage.Id + "').click()}, 30000)

This is a bit hard to explain in a simple post but I hope this helps you get further.

if you want ajax, take a look at this
This will give you a basic info of how you should do it.

I didn't dive in the jquery stuff of OS, because at the last project I was working on we could not use the OS.js

thanks to all