Injected controls use Javascript to send HTTP POST requests to the API. The API is implemented directly in the Xojo Web app. To resolve the issue where Xojo doesn't know about events that occur when users interact with the injected code, the CodeInjector module includes support for a special, and relatively simple, API. (If you're interested in learning how the injection works, take a look at the InjectedControl control's "InjectCode" method.) It essentially replaces the code that the control originally consisted of. ![]() the "Shown" event fires), the code is injected into the page. When a Web page loads and the control is displayed (i.e. The only difference is that it includes a "Code" property, and that's what you use to specify the code that you want to inject. The control appears in the IDE just as a normal WebHTMLViewer does. The code can consist of HTML, CSS, and/or Javascript. It's a subclass of WebHTMLViewer, and you can use it to inject code into a Web page. To resolve these issues, I developed a Xojo module that I've been calling "CodeInjector." It includes a couple of classes, and a handful of methods, that make injecting code a little easier. There's no way to add a "Pressed" event handler (or any other event handler) to the injected button. For example, suppose you add a button via a WebHTMLViewer. ![]() The other issue with using an WebHTMLViewer to add code to a Xojo Web page is that the Xojo app doesn't really know anything about the code that was added. Doing so will cause the browser to parse the added code and properly add it to the document.) (To get injected JavaScript to work, you have to add it using the browser's Range interface, and specifically using its createContextualFragment() method. The code will be added to the document, and you can even see it if you view the page's source. However, there are two big issues with that approach.įirst, while the HTML and CSS that you load into a WebHTMLViewer will be reflected in the Web page, any Javascript that you load will not work. ![]() It occurred to me that I could easily add code to Xojo Web pages by using the Instead, I wanted to be able to create and modify the code as quickly as possible. However, I didn't want to use the Web Control SDK to create custom contols in order to re-use the code. While working on those projects, there were several times when I wanted to use code that I had previously written for non-Xojo projects - things like Bootstrap components, complex HTML forms, and so on. I've primarily been using it on projects where a Web app is needed that integrates with NetSuite. Over the past several months, I've developed several Web applications using Xojo and the Web 2.0 framework.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |