Web Connection Feature Demos
Distributed and Enterprise Samples Web Connection Admin Page (ASP)
Web Connection

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

Basic Functionality Demos

Simple Dynamic Request

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

Simple Data Query Example

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.

Client Name:

Creating HTML Forms

Data Input and Interactive HTML Forms

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.

FoxPro Code in HTML Templates

Web Connection supports templating via an ASP style script mechanism using <%= Expression %> tags to allow FoxPro expressions and self-contained script blocks to execute. Expressions can be simple such as field values from a database or complex making calls to FoxPro or user defined functions and class methods.

This example executes a bit of code at the top of the page to execute a query that creates a cursor which is then displayed using various FoxPro expressions and script blocks.

Client Name:

FoxPro Code in HTML Script Files

Like templates, scripts execute ASP style expressions and codeblocks using Visual FoxPro code. Unlike Templates however which are evaluated every time they are run, Scripts are compiled into real FoxPro prg code on the fly and then executed. This makes them more flexible but also a little slower as files have to be created on disk (at least for the first execution) that are then executed.

Hello Script World
Customer Table Lookup
SQL Server Pubs Author Editor (ShowCursor and Edit Script)
Object Scripting Demo

Scripts or Templates?
Both scripts and templates have their pros and cons. Templates are low maintenance: They are text files read from disk and they are evaluated with no fuss. They can be updated and immediately show their changes. There's no compilation and no issues with versioning. They are very fast for expression evaluation, but fairly slow if lots of script blocks are fired. Scripts are more flexible because they are real FoxPro programs. Scripts have more overhead because versioning must be checked before execution. Finally scripts cannot be reliably updated while the server is executing more than a single instance. This is because VFP cannot detect a change to an already loaded PRG file automatically and there's no way to unload code in another server short of restarting the server. For development with single instances though changes can be made without restarts.

Document Generation Alternatives

Create Printable Documents from your VFP Reports

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:

Run PDF Report

Company to lookup:

PDF Engine Requirements Notice:
In order to create PDF documents using the wwPDF class you need to have one of the supported PDF drivers which include: Adobe Distiller, GhostScript, XFRX, AmyUni or ActivePDF. Please check the documentation under Class wwPDF for information on setting up each of these drivers.

Generating HTML Tables from Data

Using the HtmlGrid HtmlHelper Class

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 Database
This simple example uses the wwSQL class to connect to SQL server and return a cursor displayed with HtmlDataGrid. Logic is no different than native FoxPro data. Code then uses templates for editing and updating of the records.
Pubs SQL database needs to be configured for this example You need to install the Pubs database in SQL Server for this example to work. This example assumes a connection string that works with the actively logged in (Interactive) user.

Paged Display using the wwSession and wwShowCursor Objects

Another 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.

Company:
   Name:
 
Cookies, Sessions,Authentication, Uploads and Email

HTTP Cookie Test

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.

Cookie Test

Session Object

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.

Please enter your name:  

Caching

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.

wwCache Example

Authentication

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...

Authentication Test

Captcha Validation

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).

Captcha Control Sample

HTTP File Uploads

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.



File Description:

E-Mail Sample

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...

Enter your email address :

Banners, Images, Graphs and Error Handling

Images from a database

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" />.

Retrieving a file as a download rather than text

This example creates an HTML document result using ShowCursor, but rather than displaying it in the browser it presents you with a File Download dialog box and a filename of ShowCursorResult.htm. This sample demonstrates how to generate a document, store it on disk, send it to the client with a download dialog and manage cleanup of the temporary files.

Download ShowCursor HTML result as a file (Show Code)

Graphing using the wwWebGraphs class

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.

Error Handling and Debugging

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.

Crash me!

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.

Company:
Name:
Distributed, Enterprise and XML Application Demos

Click here to go to the Distributed and Enterprise Sample Page


  © Westwind Technologies, 1995-2009