Omnis Technical Note TNWE0027 Oct 2013

Creating Dynamic Web Forms

for Omnis Studio 5.2.x/6.x or above (tested on IE, Firefox and Chrome with an IIS server)

This tech note and sample library were provided by Omnis developer Kris Geerts (www.it8-projects.com) in the Netherlands.

I'm new to thin client and only did some basic html editing, but a lot of Omnis development. I found that the HTML pages which are auto-generated by Omnis, which contain the Omnis JavaScript Remote Form, can be integrated into existing web sites. However, I found it difficult to merge logic into an existing website and Java Script remote forms, so I developed a way of creating HTML pages containing the JavaScript Client in a dynamic way. This scenario also could be useful when you want to have different libraries (different versions) connecting to different databases served by one Omnis/MySQL process (like a multi-tenancy approach as you would do in the cloud). As a result, you would have several almost identical libraries with the same named forms. In this case, it might be very difficult to keep things apart and to maintain. So this might be another good reason to create some remote forms dynamically. But enough about the possible reasons, I think there are many.

First make sure you have a working web server environment. To do this you could test the HTML page generated automatically by Omnis containing your Remote Form from within your development environment (127.0.0.1/jshtml/<remoteformname>.htm ), which uses the built-in Omnis web server. So you don't need a personal web server for this to work. However, if you want to port the solution to a real web server, it is very important to have all the referenced files and the HTML pages in the correct directory of your web server. Also first make sure your web server is working properly. On IIS (Windows) you should have the following directories and files:

Inetpub (normally on c:\inetpub)
  Cgi-bin
    omnisapi.dll
    nph-omniscgi.exe
    ……
  Scripts
    nph-omniscgi.exe
    nph-owscgi.exe
wwwroot
  scripts
    omjqclnt.js
    pie.htc
    …
Css
  Omn_menu.css
    …
    Smoothness
      Jquery -ui-…
    Images

      Header-columns-bg.gif

I actually have two scripts directories. So copy the content of your 'HTML' folder from the Omnis development installation tree to the root of the web server's html root. Also check that you are using the latest version of the omnisapi.dll (or nphomniscgi. exe) and other scripts (in the folder \Clientserver\ server\cgi). Now your static created html pages should work from the root. If not, first create a simple static html page and place it into the wwwroot and try to open it with a browser. If you are testing from other machines, be careful to open the right ports on the firewall, etc. Ok, we have a working server, so what next?

To test the demo library, open the LOGIN.lbs library on the Omnis Server. Paste the following URL into a browser, replacing all three <> values with the correct IP address and port number:

http://<WebserverIP>/cgi-bin/omnisapi.dll?OmnisClass=rtDir&OmnisLibrary=LOGIN&OmnisServer=<OmnisserverIP>:<Omnisserverport>&param1=CompanyName

Note: I use only one parameter along with my first call for this demo, but you could of course add additional parameters (param2=whateveryoulike, etc.). The example handles four parameters, but you could have more. If you would like to use a basic html form to access the login screen, please have a look at the 'statical-Submitexample' in the rtDir Remotetask in the example library. In order to provide a more comfortable login for the user, I use the above approach.

When the above URL is submitted my rtDir Remote Task class generates an HTML page, which contains the Omnis JavaScript object (see $CreateDynam under the remote task rtDir). This way I would be able to open another library, even on another server, or any existing form and merging in what I need to get it working. For demo reasons I make a call back to the same library to the form rLogin (so it is important not to rename the library at first).

As you see in the example library, I use hard coded paths to my css folder and others, because I have noticed that an HTML page returned by the Remote Task is relative to the 'cgi-bin' and not to wwwroot. This means that instead of 'http://server/<filename>.htm' the following URL path is being used: 'http://server/cgi-bin/<filename>.htm'

Once the dynamically created HTML page (with your own parameters filled in) is sent back to the client, you can click on 'login'. In the library you can see that the JavaScript application can do things based on the parameters from your thin client call.

Have fun! – Kris Geerts

Download a sample library from Kris: LOGIN.zip
(for Studio 5.2.x, convert for Studio 6.x)