Visible code in browser

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.

Is this correct?

Dave

Hi Dave,

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.

Hope that helps!

Yes, but does webpage.close remove the data from the browser?

Dave,

I’m a bit rusty on Web apps, so I went to the documentation. I found the following:

“To properly clean up and remove a WebPage you should call the Close method…”
( https://documentation.xojo.com/topics/web/web_app_optimization.html )

…I also found some info on Security…
https://documentation.xojo.com/topics/web/web_app_security.html

…but so far I have not found much on what persistent data or residual data you may have to consider dealing with.

Are you concerned about using ‘localStorage’ on the client browser and Javascript that may be placing persistent data there?

Closing the page won’t remove data the browser may have cached.

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.