As a former Xojo user and now a Node.js/ Javascript developer I would like to post this question (specially for Ricardo Cruz).
Can Xojo Web use plain Javascript Components?
What would it take to include them in Xojo Web?
Having the ability to include Javascript Web Components into Xojo, in my opinion, will definitely increase the capabilities of Xojo Web.
Please guys pass this message to Ricardo Cruz.
Ricardo, estaria interesado en platicar contigo o hacer un test en como implementarlos. Creo que las oportunidades serian inmensas para Xojo Web. Pero a lo mejor no es el camino que Xojo quiere, tecnologicamente hablando.
That is where the idea came from. To be honest it seems a little more complicated than creating it in Javascript, thus the question.
There are thousands of already created and free to use web components, imagine if we are able to include those in Xojo Web easily.
Here is one of the many free components. Free components
I have seen some Xojo Web developers create WebSDK controls from free JS components.
They say it is not hard but they know JS and understand what Xojo needs for the WebSDK.
Edit: and you can ping @Ricardo_Cruz and he may comment if he is available.
If you have a Feature Request, then you can create an Issue in https://xojo.com/issues
Since it is plain Javascript no need to download any frameworks.
Frameworks nowdays is a hot topic in the Javascript world. Everything in life is like a pendulum., same in the Javascript world. Not long ago Single Page Applications (SPA) used to rule the world, now we are going back to where we started (server side).
I have wrapped many JavaScript libraries and components in GraffitiSuite Web Edition using the WebSDK. It’s doable, and not overly difficult if you know both JavaScript and Xojo.
I’ve made a few tests with React and it works just fine, using the Web SDK. I’m pretty sure it should be even easier with vanilla Web Components, the only problem is browser compatibility seems to be a bit low.
If you plan to build your own Web Components, take a look at Stencil JS, it should make things a bit easier.
I’ll more than happy to prepare an example or two using Web Components, as soon as I come back from my parental leave
These creates “Shadow web components” which are much faster then Virtual DOMs components.
All CSS is encapsulated (meaning they only affect the component not the html page or other components)
The class that you use to create the components is probably 80% the same. The only thing that changes are how you want to handle the callbacks.
I am not well versed on the WebSDK, but I can only wonder if Xojo Web can become a product where it can bring developers at the level of Javascript developers.
Here are my thoughts on what it would required:
Implement in Xojo an easy GUI to create Plain Web Components.
Make it easy to bring already created Web components. Most of the time is a file import in the HTML.
Make it easy to catch the events of the components so we can handle them using Xojo code.
These two are tied together. The problem is that the Xojo IDE has no way to “know” what would run better on the browser vs sending the method call all the way back to the server, not to mention what calls could be done asynchronously.
You really ought to look at the WebSDK though. The whole point was to make it easy for developers to add their own controls to the Xojo ecosystem and a generic control is less than 20 lines of wrapper code. I think you’d find that most of what you’re asking for is already there… including the ability to draw your controls right in the IDE editor.
I’ve wrapped the Web Component you’ve created into a Web SDK control. I didn’t have to touch your code, but I’ve added a “text changed” event, so you can also control it from Xojo code.
Hi Ricardo, thanks for the example and also Kudos for putting it in Github.
I know it has a been a year since you kindly created the example using a JS plain Web component I created. I finally had some time to look into it. After looking at your example, I see great opportunities to expand the capabilities of Xojo Web. I am almost certain that we can bring the full power of the web (Javascript) to Xojo.
Gracias por todo el esfuerzo que hiciste, de vez en cuando te voy a mandar unas cuantas preguntas
Hola @Ricardo_Cruz , here is a little diagram that I created to wrap my head around the WebSDK. This diagram is based on using a web component. Any suggestions are always welcome. I can now “hook” any Javascript component and be able to communicate from Component (JS) to Xojo Web Server and viceversa. Next goal is to see if I can make a free component library work with Xojo Web. The one I am looking at is called Shoelace.
Here is a screenshot of a Shoelace button. Once you understand how the WebSDK works, it becomes pretty easy to include almost anything available on the web!!
On the screenshot you will see a plain Web component button I created the one it says “Reset Text”
The one that says Shoelace Button is a Shoelace Web Component button. see the Shoelace Button