The following examples generate output dynamically using Visual FoxPro and Web Connection. These samples are not meant to be flashy, but to give you a functional overview of what you can do with Web Connection from simple tasks to more advanced features. If you're testing these samples on your own Web server make sure that the wcDemoMain.prg sample program is running in a Visual FoxPro session before selecting any options on this form! You can view the code for each of the routines by clicking on the [Show Code] option on the footer of each result page.
Web Connection 5.0 Web Control Framework Demos
The powerful new way to build rich Web Applications quickly
General Functionality Demos:
Creating HTML Forms and PDF Reports
Generating HTML Tables from Data
Cookies, Authentication, File Uploads
and Email
Banners, Images, Graphs and Error Handling
Distributed, XML and Enterprise Features
West Wind Message Board
What would any kind of development be without the Hello World request? The following link shows a dynamic request that says hello and returns server and form information from the Web server.
Hello World with Web Connection
The following form is basic query that allows you to query a time and billing database by selecting a client name and date range. Output is generated as an HTML table using low level output of Response.Write(). To see a list of clients and pick one from the list click on the Client Name header button.
Guest Book Application using Html Templates and HtmlHelpers
This small applet shows a guest book using basic FoxPro table access to a single table.
The sample uses Html Templates stored on disk with FoxPro expressions embedded into
the page and the new HtmlHelpers for simplified Html control creation.
If you're willing to create documents that don't use HTML you can view and print VFP reports with all formatting intact in the popular PDF format. The document can be either sent back directly or be linked on a result page. The following allows you to run a customer query and return the result as a PDFs document. To view this demo you must have the Adobe Acrobat reader installed:
HtmlDataGrid and HtmlRecord Sample
The HtmlGrid class provides an easy way to render an HTML grid from FoxPro table data. The grid displays FoxPro data in a nicely formatted HTML table that optionally supports paging. You can either use automatic column generation or explicitly generate specific colums to display.
HTMLDataGrid Against the Pubs SQL Server DatabaseAnother example showing the customer list, but this time using a paged display that shows only 5 records per page. It uses the wwSession object to capture and store the filter for the query below on each hit, then re-run the query for each of the pages to display. The user is tracked with an HTTP cookie which is used as the Session ID for the Session object.To see the full paging effect leave the query blank, then try 'A' or 'B' for short results.
The following link assigns an HTTP Cookie with a lifetime of the Browser session. Cookies are great for keeping track of users when transactions spans multiple pages or forms. This example simply creates a Cookie and displays the value. If cookies are supported by your Browser the value should stay the same on each refresh, unless you stop and restart your browser.
The session object allows tracking users through a site to keep state between requests. Users are logged and can be timed out using an automatically managed HTTP Cookie. The Session object allows storing of dynamic variables which are persisted across requests. Data is stored in a table which can be extended to match your user tracking needs.
To check this out, run this request several times and create several variables. Then go back and change a few of the values in this form. To clear any variable leave the value blank. If you haven't done so already, run the Paged Display example above then re-run this request to see the query string stored in the session object. Each variable persists across each request and can be accessed from any Web Connection server.
Caching with the wwCache class allows you to cache frequently generated HTML and XML fragments or other string based content to avoid having to regenerate it each time. If content is relatively static (such as certain list on your site for example) you can cache the output or the data (in XML format) with the wwCache object to avoid hitting the database and regenerate the HTML.
This link pops up an authorization dialog and forces you to log in. If the correct passwords are used you're allowed to see the page. If you visit this page again, you will not be asked for a password again, since the Authentication information is passed back by the Web server for each request once validated. You can try Guest/Guest as username/password to log in...
In these days SPAM on Web sites is a major problem and any open access page that accepts post input and echos it back is likely to be targeted for SPAM attack. One approach to overcome this problem is to use a CAPTCHA control which display an image code that the user must enter into a text box. Because the image is generated separately from the request and it's an image it's not very easy to spoof a CAPTCHA test. The Captcha Control can be used in Process methods (shown here) and is also available as a Web Control (shown as part of the WebLog Sample).
Browsers support the ability to upload files over HTTP to a Web server using multi-part forms. The following form allows you to upload a file to the Web server which is stored in the server's TEMP directory. Files are uploaded as plain binary, bypassing the slow URLEncoding process both on the client and server making this an efficient way to send files to the server.
The following example shows off Web Connection's ability to send SMTP email using the wwServer's SendMail method, which is implemented using the wwIPStuff DLL and class library. Enter your e-mail address below and Web Connection will reply by sending you a form email message...
You can also load images through Web Connection from data that is contained on disk (not likely, but you can <s>) or from a binary image stored in a memo field. The following image is loaded from a memo field image of the Web Connection badge logo GIF:
This image was loaded with <img src="ShowImage.wwd" />.
Download ShowCursor HTML result as a file (Show Code)
The wwWebGraphs class is a wrapper around the Microsoft Office Web Components which can be used on the server to generate graphs on the fly. This class works with cursors by providing a table with a column for labels and additional columns for one or more data series. This example creates a cursor on the fly from the data entered here:
Here's a real world example that uses graphs to chart stock portfolio information using the wwWebGraphs class.
The following request generates an error in Visual FoxPro code. Depending on the setting of the DEBUGMODE switch in the Web Connection header file, the code error will either stop on the error line, or create an error message page and log the error to the Web connection log file. Note: The shareware version has the DEBUGMODE flag set to .t. and will always stop on the error.
Error handling is also provided for the dynamic page creation with ShowHTMLFile() and ShowMemoPage() which take HTML and embed FoxPro code. The following link demonstrates how errors are handled in these scripted HTML pages.
Throw an error in a scripted HTML page or run the error.wc directly.
Show Request Data on Web Page
You can also show the current request data that's being provided by the Web
Server to the end of the HTML page by setting the wwProcess::lShowRequestData property
to .T. You can also do this globally with a configuration switch setting in the
server INI file with ShowRequestData flag.