I’d like to build an application that presents various “forms” for a user to fill out. I’d like to build the “forms” in Xojo, but not have them be part of the “parent” application. I’d like to have my Xojo Web App read “something” off of disk and “load the form”. Normally in Xojo I build my Forms in a “container control” and I place each container in the app and display the container when needed. Is there some way to off board the containers so adding new ones doesn’t require updating the application. I’m thinking that is more or less what the Xojo IDE does. You can open multiple projects…read them from disk…and run them (in the debugger). Of course the Xojo IDE isn’t a web app. If the forms were pure HTML then I could probably load them in an HTML Viewer – but writing “code” to perform complex server side actions is problematic. I’m just wondering if it’s possible/practical to load a Xojo Container dynamically from Disk in a Xojo Web App? Guessing each Page has to be it’s own unique mini-Xojo-webapp. Perhaps I need to write my own “Container description language” and then create a container instance and dynamically add the controls at the desired locations? Maybe somebody has a better idea?
I think having your own “Container description language” is probably getting close to what you’ll likely need to do. At the very least your WebApp will need to have the building blocks (WebContainers) compiled in but you could conceivably describe the hierarchy of those components and then instantiate and embed them within each other and the page dynamically. You’ll likely be using introspection to ensure everything hangs together, but you’ll probably need one (hidden) version of each of the WebContainers embedded in the page that you can clone and embed in the page/view/container as required.
You could likely use any file format that allows for items within items, JSON is good for its flexibility, if you hate yourself you could use XML, yaml is a candidate too. You could even use SQLite as a custom file format with tables that describe all the things, but that’s probably a step too far!
Quite a project, it’ll be fun!
NOTE: I’ve not done this, so don’t take any of what I say as anything but idle thoughts on an interesting project!
You dont need introspection for this. [quote=374461:@Ian Jones]but you’ll probably need one (hidden) version of each of the WebContainers embedded in the page that you can clone and embed in the page/view/container as required.[/quote]
He shouldnt. In the web framework, new controls can be created on-the-fly. If he needs a template of any kind, Id expect it to be a single empty container control which can be instantiated and used as a container for newly added controls.
It shouldnt be. If you include a hidden form element whose value is the Session.Identifier, you could get access to the form values in App.HandleSpecialUrl or App.HandleUrl and direct the values to the correct session.
[quote=374467:@Greg O’Lone]@Ian Jones You’ll likely be using introspection to ensure everything hangs together,
You dont need introspection for this.
@Ian Jones but you’ll probably need one (hidden) version of each of the WebContainers embedded in the page that you can clone and embed in the page/view/container as required.
He shouldnt. In the web framework, new controls can be created on-the-fly. If he needs a template of any kind, Id expect it to be a single empty container control which can be instantiated and used as a container for newly added controls.[/quote]
I’m confused, how would he get (for example) a new instance of his WebContainer based
CustomDatePicker control embedded in the target page/container having parsed the string “CustomDatePicker” from his text based file format?
This is really a news: the docs states exactly the opposite i.e. that only webcontainers can be created dinamically.
I don’t know if this is a lexical confusion or something never clearly explained.
The <https://xojo.com/issue/50761> submitted by me and “closed by design” was exactly related to the inability to add an empty container to a webpage.
Please Greg, can you clarify?
Interesting idea on getting the values from an HTML form. I figured that I could create a text like (perhaps JSON) container descriptor that describes the container by telling me what controls to put where…as long as I have a single container blank container control I could determine what kind of control needs to be instantiated and where. Just dont think I could put any code behind since Xojo Code has to be compiled. I was thinking about the save project as XML functionality and wondering if I built a container and saved it as XML if there would be some way for to load it and run it inside a Xojo app. I havent tried nesting Xojo apps inside each other which might be a possibility. I nest Xojo inside other non-Xojo web apps using an HTML viewer type control. If I create a web button dynamically…how do I dynamically add a click event? Seems like Id have to subclass web button for each dynamic container. Was just hoping somebody would point out some magical way to import forms into a running app. Hey you have all been great though! Thanks for sharing your ideas!
AddHandler theButton.Action, AddressOf theMethodToCall
As for code, you may be able to accomplish what you want using XojoScript as its a compile on the fly feature.
What does this mean?