WebSDK - Is this possible?

Just now really dabbing into webSDK, and from the looks of it… it’s more oriented toward objects/classes. What I need is something that can pull javascript variable information and assign it to an internal string variable during the session.prepareSession eventHandler.

ie.:

dim xojoVersion as string
xojoVersion = getJavaVariable(“Xojo.version”)

Has anybody had any luck or progression in this? I can do what I need using a custom webTextField I created a few months ago… but that’s constructed AFTER session.prepareSession, when a webPage is loaded. I can’t seem to wrap my head around to do what I need here. Any suggestions or advice would be appreciated. Thanks…

The websdk is aimed at controls, and currently there’s no way to do anything as early as PrepareSession.

Part of the reason is that it’s all asynchronous. You’d need to actually send code to the browser before you can get something back, and when PrepareSession fires, no data has been sent to the browser yet. However, we have received cookie information. Could you save an identifier in a cookie and retrieve the data from a database?

Greg, I can… what I’m initially trying to do is access information from sessionStorage / localStorage. I can call:

me.executejavascript(“localStorage.setItem(‘mykey’, ‘someValue’)”)

from within preparesession. Was just curious if there was a way to retrieve that information in something like:

dim myKey as string
myKey = javaVariable(“localStorage.getItem(‘mykey’)”)

I’ve seen a feedback ticket submitted to add the handling of sessionStorage / localStorage. I’ve added that to ‘My Top Cases’. Hopefully sometime soon we can see it get implemented.

You’ll never be able to directly access a client side storage mechanism like that because the request and response won’t be in the same event loop. Best we could do would be to send a request to the browser and then fire an event on the server… But it still won’t happen in PrepareSession. There’s no framework on the browser yet at that point.

Fwiw, one way to do this early in your app is to make the initial webpage completely blank (or perhaps a logo) and put your initializer “controls” on there… And for that you can create tray-only controls.

Alright Greg, I’ll miss around with your suggestion and see what I can get working. Appreciate the feedback.