I'm looking at working with a 3rd-party service (descope), and it show examples where you have to set up an HTML page that refers to some JS libs as well as defines some variables (eg., a jwt) and then there's some js code to process what's in the page. Sometimes they refer to fields and other HTML entities. For this particular vendor, they manage logins and authentication, so the HTML pages can be login forms, although they have a drag-n-drop form designer that you can use to build your login forms and simply use them.
But what I'm wondering is for examples that use an HTML form this way, how would one go about replacing it with a WEB Core form?
it seems like it would be somewhat mechanical / straightforward; are there any videos or explanations that show what would be involved? (Do I need to offer a detailed example?)
When creating an app with TMS WEB Core, the elements you drop on a form can be assigned an ID using the ElementID property. This works for TWebButtons, TWebEdits and so on.
If you already have an HTML form, you can load that in to the HTML file that is created when the form was created (Unit1.html for example). If it has buttons and edit fields with an ID, these can be directly mapped to components on the form with the same ID.
JavaScript libraries can be added to the Project1.html file, where you can find the <head>
stanza for the project. Here you can add in links to CDNs or to local scripts if they have been added to the project directly. Common JavaScript libraries can also be found in the Manage JavaScript Libraries feature within the Delphi IDE's Project Manager window.
JavaScript code can be added to an ASM...END block. Often the best place for this might be within the WebFormCreate procedure, but it depends a little on what the code is doing. If it is adding things like addEventListener calls to elements, this is probably fine.
Depending on your comfort levels with both Delphi and JavaScript, it might be that code can be added to other places, like the button click events or onChange events of the edit controls. Or if the code is waiting on other events, like 'onLoad', then there may be other choices as well.
1 Like