Paradox has many features that integrate, use, or support the Internet. You can add simple hyperlinks to your applications or build a complete Internet site using Paradox as a web server. This chapter will introduce you to techniques for utilizing Paradox on the Internet.
Note: There is a great PDF document included in the Reference Center on the Paradox CD titled jPdox Web Utilities which documents how Paradox integrates with the Internet. In addition to reading this chapter, I suggest you read that document as well.
Setting up hyperlinks
Paradox supports the following Internet protocols for hyperlinks:
HTTP
FTP
MAILTO
GOPHER
NEWS
TELNET
When you execute a hyperlink in ObjectPAL, Paradox will use the appropriate Internet protocol to follow the link (for example, HTTP will launch the default browser and MAILTO will open a new message in the default mail program).
Launching the Default Browser
You can add the ability to launch the default browser and display a web page. This is particularly handy these days for adding options to the Help menu of your product. For example, you can add the following options to your Help menu (each pointing to a separate page on the internet): Product Support, Product Upgrades, FAQ, and Order Information. To add a button to a form which launches your browser to the home page of Prestwood Software & Consulting, do the following:
method pushButton(var eventInfo Event)
StartWebBrowser("http://www.prestwood.com")
endMethod
Hyperlinking with the Text Expert
This next section will also set up a hyperlink this time using the Text Expert. To follow this example, make sure the Run experts when creating objects on documents is checked on the Experts tab of the Preferences dialog box.
Step By Step
Create a new form and place a text object on it. The Text Expert wizard displays.
Type PrestoNet into the text field (see figure 1). Press Next.
Figure 1: Text Expert Dialog 1
Set the style of the text (see figure 2). Press Next.
Figure 2: Text Expert Dialog 2
Select Hyperlink and type http://www.prestwood.com (see figure 3). Press Next, then Finish.
Figure 3: Text Expert Dialog 3
Notice the link has the default characteristics of a hyperlink. Whenever you use the experts it is a good idea to study the ObjectPAL that was added. In this case, take a look at the mouseClick event of the text object.
Importing Data from HTML Pages
You can use the HTML Import Expert to import data in tables or lists embedded in HTML pages. To get to the HTML Import Expert, select Tools | Experts and select the HTML Import option (see figure 4).
Figure 4: Opening the HTML Import Expert
Publishing to HTML
Perhaps the most common technique you will use to publish Paradox data on the Internet is to use the HTML Table Expert. This expert offers both static and dynamic publishing.
Web Server Repository
Use the Web Server Repository to store, view, and edit GXEngine templates for dynamic HTML publishing. The Web Server Repository is a set of Paradox tables located in the websrv/WebRepos folder. Whenever you use File | Publish to HTML and select a dynamically published document, it is also added to the Web Server Repository. It is a storage facility for HTML template files. Click Tools | Web Server Repository to view a list of stored templates. Choose the Template tab to view their contents.
Publishing Static Documents
Static documents are generated once as HTML and do not change. The benefit of static pages is that they can be posted to any type of Web Server (NT, Unix, Mac, etc.). Paradox can publish simple forms, tables, and reports as static documents. Use the File | Publish to HTML" (forms and tables) or "File | Publish As | HTML" (reports) while you have either a form, table, or report open.
When you have a form open, you can publish it as a static HTML document. This feature works best with simple forms that use text, edit boxes, list boxes, radio buttons, and check boxes. Form objects such as graphics, table frames, crosstabs, notebooks and charts do not translate statically to HTML.
When you have a table open and select File | Publish to HTML, the HTML Table Expert displays. The HTML Table Expert allows you more freedom than publishing simple forms. You can choose which fields, the HTML title, color scheme, whether you want the document to be static or dynamic, and whether you want to save the document as an HTT document. Figure 5 shows the Customer table in Netscape after the table was published as a static table.
Figure 5: A static table document
With the Report in Run Mode, you must Select File | Publish As | HTML to display the Report HTML Expert. The HTML Report Expert gives you more options than either static table or form documents. When you use bands in a report, the HTML Report Expert offers you the option of having drill down data. For example, the Customer report is grouped by Country. When you publish it to HTML, you have the option of having one page for the whole report or one page listing all the countries and one page for each country. Refer to figures 25.6 and 25.7.
Figure 6: The first HTML page of the Country report
Figure 7: One of the linked pages from the Country report
Publishing Dynamic Documents
Dynamic pages are built every time the web page is called. Dynamic pages can use either the Corel Web Server or the Corel Report Server. Since these two servers only run on Windows based machines, you are limited to distributing your dynamic pages to Windows based machines like NT.
Roll out the Paradox Internet servers
Paradox comes with several Internet servers you can use to serve up documents to browsers, set up servers on the Internet, or set up your own Intranet. They are the Corel Web Server, Paradox Report Server, Paradox JDBC driver, and JDBC Proxy Server. If that isn't good enough for you, you also get a complete web server in the form of an ActiveX control so you can write your own web server in Paradox using ObjectPAL. (This last one is demonstrated at the end of this chapter.)
The Corel Web Server
The Corel Web Server is a Windows based application and runs on Windows platforms including Windows 95, 98, 2000, and NT. The Corel Web Server acts as an intermediary between Web browsers and Paradox. However, Paradox does not need to be running (or even installed) on the server. The BDE does need to be installed in order to retrieve dynamic reports from the web repository, which is a set of Paradox tables. The Corel Web Server is a fully functional Web server with the following features:
HTTP support (version 1.0 and many 1.1 elements)
file caching
contact (access) logging using the CERN/NCSA Common Log Format plus transaction logging
The Paradox Report Server is a Java 1.2 based application that MUST run in a Windows environment. It receives requests from the Paradox Servlet running on a Web-Server(which may be running on the same machine or another machine) and returns the appropriate dynamic HTML web page back to the Web Server. The Report Server forwards web page requests to GXPublish.dll which then produces the HTML page generated dynamically from Paradox tables. Because the Report Server works with GXPublish.dll which then works with the BDE the Report Server must run on the same machine that Paradox is installed on.
Contrast this with the Paradox Servlet (dynpub.jar) which is also Java based, that may run in any environment with a Web Server that supports the Servlet API.
The Paradox JDBC driver
The Paradox Java Database Connectivity ( JDBC ) driver consists of two parts: the JDBC Client & the JDBC server. The JDBC client is available as a jar file, PdxJDBC.jar & is used by a Java Client application/applet to access databases through the JDBC server. The JDBC driver acts as a JDBC-BDE bridge providing a JDBC interface to Paradox. It can be used to access databases accessible through BDE. The JDBC server must be running on a machine with the BDE and is necessary for all transactions involving Web Form Designer clients.
The JDBC Proxy Server
The JDBC Proxy Server is a JAVA based application and runs on any operating system that supports JDK 1.2 including Windows, Unix, and Macintosh. A proxy server is a server used by companies as a security precaution. A proxy server takes requests from clients (typically a web browser) and passes them to the Internet and it also receives replies and passes them to the appropriate client. This layer is where security is usually enforced (the term fire wall is commonly used to describe this process). The JDBC Proxy Server sits between the JDBC Client and the JDBC Server and allows you to set up security.
The JDBC Proxy Server is used to enforce a 3-tier setup for the Paradox JDBC driver with the JDBC Server running on a machine which has access to databases & the Proxy Server running on a machine exposed to the outside network. This allows databases not to be exposed directly to the outside world and allows applets which use the Paradox JDBC components to be setup on a different machine which is running the web server. The Proxy Server takes all requests from the JDBC client & passes them to the JDBC Server, making it appear to the clients that it is the JDBC Server
The proxy server is also necessary when the BDE and JDBC server are located on a machine other than the machine the web server is installed on. The web form, which is a Java applet, makes a direct connection to the JDBC server once loaded. The Java security model, under normal circumstances, does not allow for connections to machines other than the one where the applet came from, so we need the proxy server on the web server machine to pass the requests to the JDBC server.
JRun Servlet Runner
This servlet runner responds to requests for dynamic documents based on the URL by passing that request to the servlet runner (JRun). The servlet runner then responds by running the Paradox Servlet which then makes contact with the Report Server. This allows you to separate browser calls from Paradox and the BDE. The Paradox Servlet (dynpub.jar) requires a sevlet runner that works in conjunction with a web server. JRun is a third party web server plug-in that provides the necessary environment to run servlets. The Web Server which can run on any operating system (Windows, Unix, Macintosh) that supports the Java Servlet API (such as JRun). The benefit of doing this is now you can have two or three tier applications. Two-tier development would consist of the client browser on any platform and a Windows based server (Web Server, Paradox, and BDE). Three-tier could consist of the client browser on any platform, the Web Server integrated with JRun running on any platform, and the Paradox/BDE server running on a Windows based server.
Creating and using dynamic documents
You create dynamic documents the same way you create static documents. You use either the HTML Table Expert or the HTML Report Expert. As stated earlier, these experts are available when you have either a table or report open. Most of the dynamic documents I create are created using the HTML Report Expert because it is more powerful supporting such features as drill down (discussed earlier), banding (grouping), and calculated fields.
To use a dynamic document is simple. Run the Corel Web Server on the machine that you want to serve up the documents (see figure 8). Paradox does not need to be running. The Corel Web Server interacts directly with the HTML document you created and the database engine to create an updated HTML document.
Figure 8: The Corel Web Server
The Corel Web Server has most of the usual settings you would expect in a web server including HTTP port, minimum and maximum connections, timeout, default page, and logging. You can view the properties by right clicking on the Corel Web Server tray icon and select Properties (see figure 9).
Figure 9: The Corel Web Server properties
The Web Form Designer
The Web Form Designer allows you to use Java browser applets to create HTML documents that any Java enabled browser running on any platform including Windows, Macintosh, and Unix can use. You create web forms using the Web Form Designer embedding JavaBeans without writing a single line of code.
As long as the server is a Windows based machine and has the BDE installed, then you can create forms that access any of the data types the BDE can. There is no custom scripting that needs to be done on the client side. Client browsers require the Java 1.2 Plug-in to view published forms created with the Web Form Designer.
The ActiveX Web Server control
With the ActiveX Web Server control you can create your own web server written in Paradox. This ActiveX control is a fully functioning Internet server with these features:
HTTP 1.0 support (plus some features of HTTP 1.1)
file caching
logging using the CERN/NCSA Common Log Format
custom MIME types
support for cookies (sessions)
support for multi-threaded containers, such as Delphi
OGI programming interface
Because Paradox forms support OLE controls as a container, you can use the ActiveX Web Server control by placing it in a form. The form is notified when an HTTP GET, POST, or HEAD method is requested by a Web browser client. The Corel Web Server Control supplies its container with an OGI (OLE Gateway Interface) event. An OGI event is an ActiveX control ConnectionPoint event. This allows the container to execute an event-handling procedure in its native code. Custom event behavior can be programmed or the default HTTP response can be accepted.
Using the Web Server Control with Other programs
Does the Corel ActiveX Web Server work with other products like VB and Delphi? Yes it does. It should work with any product that supports OLE controls as a container.
A Paradox Web Server
This final example demonstrates creating a Web Server written in Paradox. This example will combine ObjectPAL, SQL, and HTML. Once completed, you will be able to use an Internet browser to select a city from the Customer table and upon pressing a button display all the customers in that city. You can do this on one machine or you can install Paradox on your server and then call the server machine name from a client machine running a web browser.
First we will build our web server.
Step-by-Step
Create a blank form and place a Corel Web Server control on it (see figure 10). The Corel Web Server control is available from the ActiveX toolbar.
Figure 10: Set up form
Alter the Var window of the form as follows:
Var
strPath String
endVar
Init Alter the Init event of the form as follows:
method init(var eventInfo Event)
var
dynFile DynArray[] String
endVar
;Get the current path of the form.
splitFullFileName(getFileName(), dynFile)
strPath = dynFile["DRIVE"] + dynFile["PATH"]
;The server is set to the path in strPath in the DoStartup
;of the ServerOCX object.
endMethod
DoStartup Alter the DoStartup event of the ActiveX Web Control as follows:
method DoStartUp(var Cancel Logical)
; This is where we set the BasePath.
; This allows the form to be run from
; any directory.
self.BasePath = strPath
;Set the default HTML document.
self.DefaultPage = "index.htm"
endMethod
OnGetRequest Alter the OnGetRequest event of the ActiveX Web Control as follows:
Save the form as web_server.fsl and run the form. Leave this server running for the next part. Figure 11 shows the web_server.fsl form after receiving several requests.
Figure 11: A Custom Paradox web server
Now that the server has been created, we need to create an initial HTML page that gets us into the system. Let's keep this simple. Type the following into any text editor (Notepad, PrestoEdit, Wordpad, for example) and save it as index.htm. (Make sure you change the machine name of badzooka to the name of your machine.)
<html>
<head>
<title>Customer Example</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>
<b>Using a Paradox form as a Web Server</b></h1></center>
Notice the HREF the link above simply says GET_CITIES. The web server OCX embedded in the web_server.fsl form intercepts this request. The form takes care of processing the request and generating the HTML to return. This is done in the OnGetRequest event of the OCX which is embedded in the form. You can also use HTML post form events to send to the OCX and those can be trapped for in the OnPostRequest event. I cold have easily used get_cities.html in place of GET_CITIES if I wanted the request to feel more like a static page.
The final step is to load your favorite browser and open your page. On my machine, the server is called Badzooka, so I type the following URL into the browser:
http://badzooka/index.htm
Because I have index.htm specified as my default page, I could just use the following:
http://badzooka
Figures 12, 13, and 14 show the pages in Netscape.
Figure 12: Initial web page
Figure 13: Choose a city
Figure 14: The customers in that city are displayed
Summary
Paradox integrates well with the Internet. You can import and export to static HTML documents or you can publish your data dynamically using the various web servers included.
With both the Corel Web Server and Paradox Report Server, you can display data in web browsers that were created with either the HTML Table Expert or the HTML Report Expert. The Corel Web Server is a Windows based machine and therefore runs on Windows platforms such as Windows NT. The Paradox Report Server, on the other hand, is Java based and is platform independent.
For interactive web based applications for use with Java enabled browsers, you can use the Web Form Designer which allows you to embed JavaBeans into HTML documents which will interface with the BDE on the server. The server must be a Windows based server with the BDE installed, but the client browser just needs to be Java enabled.
If all of the servers that come bundled with Paradox are not enough for you, you can write your own web server using the Web Server ActiveX control included. This is a great way to take full advantage of Paradox and all of its features including ObjectPAL, TCursors, queries, and SQL. With this solution, you must build the HTML documents in your code, but you have the freedom and power to do anything ObjectPAL can do. This final solution does not require a Java enabled browser but the server must be a Windows based server running Paradox or Paradox Runtime.
Paradox and the Internet and more is included as a page content. You will also be check essayassignmenthelp.com.au which is showing you as more coding you will be see it in page as all coding is explain as well in a good method.