I’ve got a timer that updates info on a webpage. When I switch to another page, it seems this timer interferes with controls on other pages, like comboboxes (it moves selected combobox items at the same rate as the timer.period.
I tried disabling the timer on the page Close event, which fires but timer stays enabled.
I’ve got a timer that updates info on a webpage. When I switch to another page, it seems this timer interferes with controls on other pages, like comboboxes (it moves selected combobox items at the same rate as the timer.period.
I tried disabling the timer on the page Close event, which fires but timer stays enabled.
Anybody knows what’s this about? Cheers![/quote]
It is a known bug.
You may want to try a server-side timer (NOT a webtimer) instead. Or refactor your code to use events, if that is possible.
The timer instance is part of the page, so of course you can call a method. However, in both WebTimer and Timer Action, you need to use WebSessionContext if you want to have access to the session to show a page or a dialog for instance, or access other session properties, for instance. Note that is the case in sockets events as well.
To be able to show a dialog, I add a property WS to the webpage which I set in the WebPage Open event as WS = Session , and in the timer Action event, I can do :
Dim context As New WebSessionContext(ws)
dim d as new modal1
d.show
[quote=243462:@Michel Bujardet]The timer instance is part of the page, so of course you can call a method. However, in both WebTimer and Timer Action, you need to use WebSessionContext if you want to have access to the session to show a page or a dialog for instance, or access other session properties, for instance. Note that is the case in sockets events as well.
Suppose I loop through the sessions and I find that this context belongs to a specific page (by name or title or maybe some better way)… If there’s a specific method on that “dynamic” page, how can I call it from an external timer event? That method refreshes the controls on that page.
For i As Integer = 0 To App.SessionCount - 1
Dim context As New WebSessionContext(App.SessionAtIndex(i))
if context.Session.CurrentPage.Name = “Page_XYZ” then
[quote=243468:@Shant Khatcherian]Suppose I loop through the sessions and I find that this context belongs to a specific page (by name or title or maybe some better way)… If there’s a specific method on that “dynamic” page, how can I call it from an external timer event? That method refreshes the controls on that page.
For i As Integer = 0 To App.SessionCount - 1
Dim context As New WebSessionContext(App.SessionAtIndex(i))
if context.Session.CurrentPage.Name = “Page_XYZ” then
’ Call the method on that page…[/quote]
You keep referring to an “external” timer event. What do you mean ? By definition, a timer has to be instanciated. Most often that will be the case on the WebPage, as it is the case for a WebTimer. Or are you referring to a timer instanciated in App ?
What do you want to achieve ?
[quote=243492:@Michel Bujardet]You keep referring to an “external” timer event. What do you mean ? By definition, a timer has to be instanciated. Most often that will be the case on the WebPage, as it is the case for a WebTimer. Or are you referring to a timer instanciated in App ?
What do you want to achieve ?[/quote]
by “external” I mean a standard Timer located in e.g. App, outside a webpage. Since a webtimer causes popup menu issues, how can I periodically update controls on a webpage without a webtimer?
[quote=243521:@Shant Khatcherian]by “external” I mean a standard Timer located in e.g. App, outside a webpage. Since a webtimer causes popup menu issues, how can I periodically update controls on a webpage without a webtimer?
thanks![/quote]
Where was the Webtimer before ? Create a class, make its super “Timer”. Then drag it to the same exact place the Webtimer was before. Add the very same code in Action, set period and mode the very same way.
I created a class called CustomTimer with super Timer. Dragged the CustomTimer to the webpage, put code in action event… it works but still while its running, the popupmenus on that page are affected.
But now at least when page is closed, other popupmenus are not affected anymore.
If I recall correctly, the main issue with WebTimers and PopupMenus that happened was that the selection was jittering.
Now, I do not see how a Timer could do the same. A server-side timer executes on the host and has nothing to do with the HTML controls or javascript, unless of course some code is added that does.
Have you removed the WebTimer ? Even with no Action event, it exists as JavaScript and will indeed keep interfering.
When you mention updating controls, are you updating the popupmenus ?
If you want to place the timer away from the webpage, you can add the Timer instance in Session as a property, use Addhandler to run a method there, and do something like :
If me.CurrentPage.Name = "XYZ" then
//Do your update
end if
Be careful, though. CurrentPage will be nil until the page has actually been created.
Yes, the effect is jittering popups…
I’m sure I’ve removed the WebTimer… Popupmenu that is affected is not being updated, it is part of a separate container on that webpage.
If me.CurrentPage.Name = “XYZ” then
//Do your update - Can I call a method that only exists on that page from here?
I’m trying to use the Timer (instead of WebTimer) by creating a class and dropping this onto my form. The event fires but I can’t access the Session or any of it’s properties (no error is thrown but the code does not continue!). Why is that? Is the thread outside of the context of the Session. The Timer is on my form which is within the Session context.
Also, in answer to earlier queries about the webtimer causing refresh problems, if you stop the timer (set to Timer.ModeOff) before the page closes then this gets around the problem. The way we’ve done this is for anything that causes navigation from a page we first stop the timer and then (ironically), we set off a ModeSingle timer that closes the page and navigates away. That way, Xojo has a chance to refresh the javascript timer to off before closing the page.