Best practices

I am updating a large energy management app and want to optimize the design. When WE first came out, there were suggestions on the forum to use one page and switch different containers in and out as needed. I got away from that and used individual webpages after discovering that containers were not scrollable on phones. Now that they scroll, I am rethinking the one page idea. The advantage is that only one container is required to center the app in the browser window and one toolbar can handle the entire app.

It is my understanding that the entire app is uploaded to the browser when the session starts and everything is pretty much javascript and ajax after that, Are there performance or other issues that suggest multiple pages vs one page with multiple containers?

Containers have always scrolled on phones AFAIK. There are just a lot of quirks with WebContainers. If you are ever using a control array of containers it’s best to embed them on the page using code rather than place them. That goes for any web project - phone or not.

Anyhow it’s not completely true that “everything” is uploaded to the phone. There is both server side code that executes and browser side code. On a particular page you may have some of both. For example, I have server side objects that execute code on particular pages. The code for some of those objects runs on the server.

Then you have timers. If you place a timer on a page, then that timer is a local timer to the page. However, if you have a timer in the App object instantiated in code then that timer is run on the server. Both are useful depending on where you want execution to happen.

I am pretty sure that each page is delivered to the browser as it is loaded. So the app doesn’t send all the pages to the browser.

Hope this helps. I’m far from an expert on this stuff myself.

What I meant when I said everything is uploaded at the session start is that all the pages are uploaded and that they are not uploaded individually as they are shown. I fully understand there is server-side code. You can’t have ajax without it.

I don’t think that is correct. Pages are loaded individually as needed as far as I know. It would be a waste of resources to delivery everything to the browser when some pages may never get loaded. I think the pages are built on the server at the start of the app but then get delivered to the browser when requested. I could be wrong but what you say has never been my understanding.

WebPages are built on the fly when you call WebPage.Show.

One of the problems with the Container approach is that if you don’t manage your containers, closing and nil-ing them when you are done with them, you may run out of memory on a mobile device. They are typically very resource restrictive.

[quote=84598:@Greg O’Lone]WebPages are built on the fly when you call WebPage.Show.

One of the problems with the Container approach is that if you don’t manage your containers, closing and nil-ing them when you are done with them, you may run out of memory on a mobile device. They are typically very resource restrictive.[/quote]
And what happens if you don’t manage your WebPages ?

[quote=84587:@Dean Davidge]I am updating a large energy management app and want to optimize the design. When WE first came out, there were suggestions on the forum to use one page and switch different containers in and out as needed. I got away from that and used individual webpages after discovering that containers were not scrollable on phones. Now that they scroll, I am rethinking the one page idea. The advantage is that only one container is required to center the app in the browser window and one toolbar can handle the entire app.

It is my understanding that the entire app is uploaded to the browser when the session starts and everything is pretty much javascript and ajax after that, Are there performance or other issues that suggest multiple pages vs one page with multiple containers?[/quote]
It seems a lot of peoples on this forum have a different view of what’s “Best Practice” regarding WebApplications with Xojo so this not an easy question to answer.

Some have a ‘page navigation’ centric vision, some have a ‘session centric’ one, some advise against WebContainers some advise the opposite. Some advise to test moving some control management action in the Open event - if issues arise - instead of in the Shown event (ahem), some will nail you instantly if you do that.

So the best answer, I think, even if it’s not very helpful, is to trust your instinct, try a way, see if it works for you, listen to the different advices, test those, make your own choices. The truth is out there but…

Trust no one :wink:
(until you’ve checked by yourself)

You are correct that you also need to close WebPages when you are done with them, but I’ve found that users are far more likely to close a WebPage than they are to close WebContainers. I suspect it has to do with the fact that on the Desktop, one usually doesn’t think about these things.

I’m just bringing this up because I see this memory issue far more often in projects that are WebContainer based than I do in WebPage based projects.

Good point, indeed.