Reducing loading time: call a method of an instantiated webpage

Hi all,

I use in order tomake my app less “heavy”

Dim APage as WebPage
APage = new AccordPage_GeneralInfo
APAge.Show

But then how can I call access a method of this page outside of the page? Whenever I try to use APage.Domymethod I got ‘this item does not exist’…

Is your method set to private?

Place your Dim for APage inside the Session object, in the Session.Open define it and access it as Session.APage.Domymethod

Jim I thought that I have checked that the method was public but not sure,Iwillcheck again.
David,I will try your advice. Thank you

I tried to follow David’s advise but it does’t work.Maybe I missed something?

In Session object, I set a property ‘thePage as WebPage’

In Session.Open I set ‘ThePage = New MyPage’

Then from my MainPage I called 'Session.thePage.Show’which works fine

But if from my MainPage I called ‘Session.thePage.ShowTextContent’ where
the ‘ShowContent’ is a public method of MyPage I get the error

MainPage.Button2.Action, line 1
Type “WebPage” has no member named “ShowTextContent”
Session.thePage.ShowTextContent

You need to cast your instance using whatever the name of the WebPage is so that it knows what methods, properties, etc. are available. Otherwise, it is treated as a generic WebPage:

AccordPage_GeneralInfo(Session.thePage).ShowTextContent
or
MyPage(Session.thePage).ShowTextContent

That should make your code work, but there are only a few, rare instances I can think of where it makes sense to make a web page into a session property. If you’re not certain this is one of those cases, you might want to just try taking the normal route which creates and uses a new instance of the page for each session:

AccordPage_GeneralInfo.show
AccordPage_GeneralInfo.ShowTextContent
or
MyPage.show
MyPage.ShowTextContent

Another simpler alternative to cast APage correctly would just be to declare it that way in the first place:

Dim APage as new AccordPage_GeneralInfo
APage.show
APage.DoMyMethod

Seth, thi swas my question at first hand. Iwas unable to call successfully the APage.DoMyMethod despite the fact that DoMyMethos is declared as Public.
I try to set implicit Instance of the page OFF, and load a webpage when I needed accordingly in order toreduce loading time.It takes 1 min and 20 sec (!). I use GraffitiSuite Plugins but yet this time seems very unusual.

This time referred to secure pages. when load it without https:// the loading time is a lot shorter.
Also I don’t think that is due to internet connection and my distance from the Xojo server…

…when load it without https:// the loading time is a lot shorter … (20 secs)

Meanwhile I removed some unused GraffitiSuite classes and now the secure pages of myapp loading time reduced to 50’’.
I think that Internet connection play a role but my distance from the Xojo server is about response time in firing things…
I’m going to move to a European Xojo Cloud Server.

I think that this will fix some issues…
Any opinions about it except a solution to instantiated webpages and successfully call its public methods?

In your original sample code in the original post, you declared APage as a WebPage, so it wouldn’t know about any of the methods or properties specific to AccordPage_GeneralInfo even if they’re public. If you declare it (NOT just set it equal to) a “new AccordPage_GeneralInfo”, the code should work fine.

dim APage as new AccordPage_GeneralInfo
APage.show
APage.MyMethod

Those three lines work fine in my tests.

Thank you Seth, I appreciate it. Do I have to put in Session object as David suggested?
Please, what about David Cox 's solution?
Any advantages over the method you suggest in terms of memory and loading speed time?

Sorry, none of my apps have had the page instantiation as a performance bottleneck, so I’ve never done any measurements or resorted to manually instantiating a page.

From a performance standpoint:
I’ve had hundreds of people slam my apps at the same time without an issue if they didn’t do anything complex, or just a couple dozen if each user’s page was simultaneously pulling data from a slow, SQLite database built into the app itself.

From a casting standpoint:
I have resorted to casting in a few cases where I had a generic method at the session or container level that needed to trigger a method on a webpage. In those cases, I resorted to something along the lines of:

MyPage(thisContainer.parent).theMethodOnThePage