I’m new to web apps and I’m creating a container that will be sitting on a webpage.
When the webpage is called, I’m passing parameters to it as in:
wPage.startup(Param1, param2)
I need the container sitting on this webpage to know what parameters were passed. I thought I could save the parameters passed to properties of the web page and then have the container reference the properties on the web page, but that fails.
How does the container know what parameters were passed to the web page the container sits on?
A container shouldn’t need to know what page it’s on. Pass the parameters in to the container during the startup
function. Wanting to reference outwards will lead to spaghetti code.
If you’re heart set on not adding a startup
function to the container, you can use Event Definitions to request values from the parent. It is much easier to pass in values from your startup
function though.
2 Likes
I think it’s better if the container knows nothing about where it’s placed. For example, in your wPage.startup
method, you could be passing some of those parameters to the container:
startup-example-1.xojo_binary_project.zip (11.8 KB)
If you really need to access the WebPage properties, you could check what kind of WebPage is displaying this container, and query the parameter you need:
startup-example-2.xojo_binary_project.zip (11.6 KB)
1 Like
Ok, that makes sense. Thank you Tom and Ricardo.