I have a URLConnection subclass created by a web page’s shown event and assigned to a property on the webpage. I have a property on the class which is set to the webpage.self. I use this class property to call back a method on the web page when the content received event is complete. Works except the method on the web page has no session context when fired. So I pass back the session context from the class with the method call (that is to remind the web page which session it belongs to) But how do I set the session context to the page? Context.Session.Page1 as suggested in the documentation, tells me there’s no web page with context.session!
So there was a URLConnection base class that was subclassed which was subclassed again, an instance of which child was instantiated by the Web page. When a method of the sub class of URLConnection was called from its child, it raised an event which was handled by its child, but the event lost the session context. However, by using Invoke from the URLConnection subclass on a method in its child, instead of an event handler, the session context was preserved, so that the web page could be accessed from the URLConnection’s descendant.
It would be nice if we could simply declare a piece of code to be in a particular session. Wasn’t that how it worked once?
Oddly, what I thought was the solution allowed a property to be changed on a control in the web page, But the text box’s changed event did not fire even though the text changed.
The IDE won’t let me handle an event of an event I make on a Web page either, so I can’t raise an event.
However when the user changes the text box the event fires…
Use a server-side Web timer to poll a computed property on the class which is set when the class’s processing is complete. (Which computed property may be reset for next use when read.)
The program flow’s session context is preserved in the WebTimer so that other web pages in the session can be accessed for example when the timer detects processing is complete in the class.
It may also be necessary to make subsequent calls to the URLConnection subclass by setting a WebTimer (server-side) if program flow isn’t completed to go back to the browser. This should allow the connection to close by restarting the call stack avoiding an error of the connection still being open when the next use of it is started.