Just a quick question, to make sure that I am correct in my assumptions,
If you have a webapp, with two screens, screen1 is the first loaded when a user logs in. Am I correct in saying that screen 2 is not visible in the browser session on the client until I show the page. If I show then leave page 2, I am guessing it stays in the browser until another page issues page2.close.
Much like a desktop app, once you ‘show’ a window (in this case a WebPage) it stays instantiated, even if you move away from it by showing another page. I assume when you say ‘screens’ you mean browser pages.
In my testing (a long time ago now, and if I’m remembering correctly), pages remained in the DOM if their Implicit Instance property was true, regardless of calling Close(). This may have been fixed at some point, but I prefer not having implicit instances of pages so I can clear them from memory when I don’t need them any longer, including associated data and objects.
Set Implicit Instance to False on the WebPage, add a public property to your Session object called something like
currentPage as WebPage
Create a method for switching pages on your Session object
Public Sub SwitchPage(newPage as WebPage)
if not isNull( currentPage ) then
currentPage.Close()
end if
if not IsNull( newPage ) then
currentPage = newPage
newPage.Show()
end if
end if
End Sub
Show your desired page
Session.SwitchPage(new WebPage1)
Note that this code is untested and may need some finesse. Just wrote it from memory. I use something similar in the GraffitiSuite demo and several customer projects to securely manage page switching.
Of course you could also make Session.currentPage a computed property and negate the need for a method, but this is easier to write from memory without firing up a new Xojo project.