The menu Professional
The first page of any Web application is accessed via an HTML page that must be deployed in a directory of the HTTP server. Depending on what gateway is used the index page INDEXEXE.HTM, INDEXDLL.HTM or INDEXISA.HTM needs to be deployed. Those index pages can be found in the ...\SAMPLES directroy. They define form actions that connect to the initial page of the Klondike Computer Shop. In case of INDEXEXE.HTM the code looks like the following:
For INDEXDLL.HTM the corresponding section looks like this:
The WAA server uses the contents of WAA_PACKAGE and WAA_FORM to call the form-function inside the corresponding package DLL. In this example, the functionMainMenu() in MENU.DLL is called. It presents the entry to the Klondike Computer Store from where a visitor can explore this Web application. The different options are available through submit buttons which are arranged in a menu-like fashion. This is the only way to create something like a menu in Web applications since there is no HTML tag that would allow for building a menu control. The usual way of using links with the tags <A HREF="XYZ.HTML"> </A> is not possible unless the linked HTML pages are available on the HTTP server. However, this is not the case because the HTML page is created by the form-function MainMenu()(see MENU.PRG).
The PRG code creating the menu page begins with the definition of a head line that precedes the submit buttons. The method call oHtml:header()marks the beginning of the HTML page definition and must be used as the first method call. The string passed to this method is displayed in the title bar of the Web browser when it receives the HTML page:
The head line is almost completely built with the method :put() which is the most versatile method of the HTML3 object. It accepts as a parameter any HTML-formatted string and puts it into the resulting HTML page. The head line is defined as a table (<TABLE> </TABLE>) consisting of one row (<TR> </TR>) and two columns (<TD> </TD>, stands for Table Detail). The left column contains a GIF image and the right column displays a string in large, blue letters using the Arial typeface (<FONT> </FONT>).
The inclusion of images in HTML pages is easily done with the method :img()in line #5, but this line needs some additional comments. The method accepts two file names for one image file! This is required because image files are included into HTML pages as a reference, or link. The referenced file must be located on the HTTP server so that it can transfer the image to the Web browser, but the Web application must find the file as well. This, however, is not possible when WAA server and HTTP server are installed on two different computers.
The solution for this problem is that the image file is copied from a directory visible for the WAA server to a directory visible for the HTTP server by the :img() method. The first parameter specifies the name and location of the image file relative to the current directory of the package DLL (this is visible to the WAA server). The second parameter does the same but the location is relative to the document root directory of the HTTP server. Note also that the WAA server directory is specified using backslashes "\" and the HTTP server directory needs the HTML compliant forward slash "/". The image file specification for WAA and HTTP server is summarized below:
If you use image files in your Web applications, you should always use the third parameter of the :img() method. This string is displayed in the Web browser if the image cannot be displayed. It gives you an immediate hint which file you should look for when checking whether the file's location is defined correctly in your PRG code or if the document root is properly set for gateway and HTTP server.
After the head line is defined, a horizontal ruler (<HR>) separates it from the following submit buttons which represent the menu. The buttons are displayed within a table just as described for the head line, so that we can focus on how to program the submit buttons:
The code defining control elements for user input in the HTML page must be enclosed by the method calls :formStart() and :formEnd(). Between both methods, the :setVar() method defines variables along with their values which are bound to the HTML page. The two variables WAA_PACKAGE and WAA_FORM are evaluated by the WAA server when a submit button is clicked in the Web browser. Since each submit button defines a different value for WAA_FORM (lines #3, #11 and #19), the WAA server will invoke the corresponding form-function so that a user can choose different parts of the Klondike Computer Shop from the initial menu page.
The end of the menu definition is reached when the :footer() method is executed, and this marks also the end of the HTML page. After :footer(), the form-function must return .T. (true) to tell the WAA server to transfer the assembled HTML page to the Web browser.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.