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

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
West Wind Developer Registry Sample
Interactive Photo Album Applet
POP 3 Web Mail Client Sample
 

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:

From:    To:

MultiSelect example:
You can also access multiple listbox (or radio button) selections using the Request.FormMultiple() method:


Creating HTML Forms

Data Input and Interactive HTML Forms

The Guest Book application demonstrates use of interactive HTML forms using Template pages stored on disk.The template contains Visual FoxPro expressions for field names and other FoxPro expressions using Active Server like syntax. This form can take input from the user and save and update the values in a table. The page contains the table fields and several expressions to display all data without having to generate the HTML in code.

West Wind Developer Registry
Here's another, more complete example that demonstrates using templates as well as the wwBusiness Business object to create a developer registry. This example demonstrates using the business object with multiple tables, handles generic user profile management and demonstrates how to selectively allow access to certain information on a per user basis. Note profiles are accessible by email + a password which is 'password' in the demo for all profiles.  (stored in wwDevRegistry.prg)

Visual FoxPro form to IE 4.0 Dynamic HTML conversion

Note: Available only in the Enterprise Edition of Web Connection

Take most Visual FoxPro forms and run them as DHTML with very little code. You can build 90% of the form logic in Visual FoxPro and use the wwForm class to actually display the form interactively. Forms can also be repopulated dynamically and automatically from a form submission to minimize form handling code. Now supports grids (read only) and PageFrames!

Check out the Controls sample which demonstrates most of the objects the class can render. Run a Simple Data form using a customer display and list in a Page Frame view. For more comprehensive examples look at the IE 4.0 Guest applet.

Note: Grids are implemented as an VB ActiveX control. In order to be able to download this control your IE 4 security settings must be set to Medium. The control is signed and ships with full source code with the Enterprise Edition of Web Connection. If you don't already have the VB5 Runtime files, these files will be downloaded and installed automatically from the Microsoft site. Full onetime install is around 1.5 meg - the actual grid control is 14k.

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.

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.

Display Data Results in Excel and Word

You can easily output content into various Office document formats and Office will pick up these documents from HTML and transform them into their native formats. The following two demos return HTML data displayed in Word and Excel. These demos require Office 2000 or XP or later.

Return a cursor as Excel Spreadsheet  (Show Code)
Return HTML output in a Word Document (Show Code)

Using Unicode and Extended Languages

Visual FoxPro doesn't support Unicode directly but with a little work you can take advantage of Unicode to handle multiple complex character sets like Chinese, Korean, Russian etc. in a single Web page, by storing strings as binary Unicode in VFP 9's new binary field types.

Unicode Language Demo Form

Locale Specific Display of Dates and Numbers

Your clientele might be international and although Web Connection can't translate your applications for you we provide you with basic Locale Support for automatically switching number and currency formats according to the browsers selected language. To try this out, click the link below and use your browser's language settings to switch into different languages.

Locale Info and Formatting Demos

Generating HTML Tables from Data

ShowCursor Class Sample

The ShowCursor class provides a very easy mechanism to display database data in an HTML view. You can view a list view, record view or ASCII dump view. Creating these views is as easy as creating the object and calling a single method. You can customize the view by setting property values on the object.

ShowCursor's EditTable method
The EditTable method allows you to browse an edit a table interactively, much as you can in a browse. You get a list view with links to edit, add and delete items from the table. Edits are raw much like you would see in a Browse window. Note this demo takes 15 lines of code - use view code to see them...

ShowCursor against the SQL Server Pubs Database
Here's a quick example how to access a SQL Server database with Web Connection's easy SQL Passthrough wwSQL class. If you have a DSN configured for the PUBS database try this demo that displays a list of SQL Authors and allows you to edit them.
Note: You need to have a DSN named Pubs to point at the SQL Pubs sample database with a username of sa and no password. You can change these values in wwDemo::SQLShowCursor() method in wwdemo.prg.

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 :

 

 

POP 3 Example using the wwSocket Class

This example lets you view the content of your POP3 mailbox. This code uses the wwPOP3 sample class which implements a  POP3 client using the low level wwSocket class.

Check your mail on your mail server

Banners, Images, Graphs and Error Handling

Rotating Banners

This link displays a different image link everytime a page is refreshed. The wwBanner class that comes with Web Connection makes this job extremely easy. For fun, add your own image reference and a link and add it on the rotation list for this sample...

Show rotating image page

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

Creating Word and XML Documents from HTML

The following simple examples demonstrates how to generate HTML and return this HTML with custom headers that let you show the result as a Word Document or Excel Spreadsheet.

Get Word Document (Show Code)
Get Excel Document (Show Code)

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.

Stock Portfolio Example

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