The chapter picks up on basic theories from chapter '24.6.10 Developing web applications with Gambas' and supplements them with the description of several web projects based on the Webpage class.
Among other things, the Webpage class implements an HTML page. A webpage always consists of two parts:
Among other things, the class has the static method Main(). This method allows you to use any web page as the start class. The Main() method uses the Render() method to output the complete HTML of the generated web page.
Using the gb.web component only really makes sense if the Internet web server has
so that you can run your web pages there based on the Webpage class!
Most users therefore only have two options for testing the developed web applications:
The author's intranet consists of three computers (desktop PC A and two laptops B and C). All computers have fixed IP addresses despite DHCP. A Lighttpd web server is installed on both PC A and PC B. The web server on PC B acts as a web server for the intranet.
The use of the Gambas programming language and the JavaScript scripting language allows you to dynamically insert or change content on a web page using a special syntax. You can use CSS to design a website in a variety of ways, which you can see here:
Figure 24.6.2.0.1: Output of an SQLite database report in a web page
An SQLite database report is inserted into the webpage 'IncDBReport.webpage', for example, using a Gambas function that is defined in the Gambas class 'DBReport.class'.
A timer is realised via a JavaScript script, with which the current time is periodically displayed in the footer of all web pages:
Figure 24.6.2.0.2: Display of the current time (footer) with a JavaScript timer
The web pages are delivered from the web server to computer B and displayed in the web browser on computer A.
The Webpage class only has two properties:
In addition to the static Main() method mentioned above, the Webpage class has two further methods:
The Gambas compiler uses the Render() method to generate HTML source code from a webpage file wp_name.webpage and from the class wp_name.class linked to it.
The Webpage class uses a special syntax - which is based on ASP (Active Server Pages) - to insert Gambas source code into a webpage *.webpage.
Syntax | Description |
---|---|
<%source%> | All Gambas source code is executed 'as is'. |
<%=Expression%> | Assignment of a Gambas expression that is converted with the Html$ function. |
</x><%–Comment–%> | A webpage comment is completely ignored, while an HTML comment such as '<!– HTML-COMMENT –>' is output in the HTML. |
</x><%/%> | An abbreviation for <%=Application.Root%>. |
«webpage> | Inserts the content of another web page into the current web page. |
«Webpage arg1=“value1” arg2=“value2” … » | Inserts the content of another web page with (optional) attributes into the current web page. Example: «AstroWebpage name=“stars” number=“7”» |
<%!arg_name%> | Delivers the value of the attribute 'arg_name.' |
</x>←-CONTENTS–> | Identifies the boundary between the header and footer within the embedded webpage. |
</Webpage> | Inserts the footer of an inserted webpage. The specification is optional if the footer is empty. |
Table 24.6.2.0.1 : Web page syntax