This WebSnap application demonstrates how to use WebSnap wizards, components, and designers to build an application that edits the content of the Country table. 

Create a New WebSnap Application

File/New/Other.../WebSnap/Web Application

File/Save All

The application will look for the HomeU.html file in the same directory as the executable so save the unit and the project to the same directory.

Set the ApplicationTitle

Click on the Preview tab in the editor window.  The application title is displayed at the top of the page.

Run the Application

If you would like to see what you have so far, Run the application.

Create a New WebSnap Module

File/New/Other.../WebSnap/Web Page Module

File/Save

The application will look for the CountryTableU.html file in the same directory as the executable so save the unit to the project directory.

Run the Application

If you would like to see what you have so far, Run the application.

Add data components to the CountryTable module

View the Object Tree View

Add Data Aware Components

Note that the Session component is needed because we are using BDE components (TTable) in a multithreaded application.  

Specify a key field

The Name field in the country table can be used to identify a record.

Add an Adapter

The purpose of the DataSetAdapter is to expose the data in our application to server-side scripting.  

Create a grid displaying data from the Country table

AdapterPageProducer components are used to dynamically generate HTML forms and grids display Adapter fields and executing Adapter actions.

View the Object Tree View

Add a grid

Run the Application

If you would like to see what you have so far, Run the application.

Add editing commands to the grid

Add Buttons

Run the Application

If you would like to see what you have so far, Run the application.  The Edit and Insert buttons won't work.  Delete will work.

Add an edit form 

File/New/Other.../WebSnap/Page Module

File/Save

The application will look for the CountryFormU.html file in the same directory as the executable so save the unit to the project directory.

Use the CountyTableU unit

Add CountryTableU to the uses list so that this module will have access to the Adapter component.

View the Object Tree View

Add input fields

Add buttons

Set Adapter Mode (optional)

You may notice that the preview for CountryForm displays static text field values rather than input controls, and that the Apply and Cancel buttons are not displayed.  This happens because the TDataSetAdapter is in browse mode, by default.  You can change the mode using the following steps.  These steps are optional because,  when the application is running, the TDataSetAdapter mode will be changed to edit when the Edit action is executed.

Link form actions to the grid page

Specify which page to display when a command is executed by pushing a button on a form.

Link grid actions to the form page

Specify which page to display when a command is executed by pushing a button in a grid row. 

Run the Application

If you would like to see what you have so far, Run the application.  All the buttons will work.  However, there will be no indication of database errors, such as invalid type.  For example, try adding a new country with an invalid value (e.g., 'abc') in the Area field.  One other issue is that the RefreshRow button will show when inserting a new record.

Add error reporting

Add AdapterPageProducer components that will display database errors that occur while editing the Country table. 

Add error support to the grid

Add error support to the form

Test error reporting

Database errors will raise an exception in the running application.  The exceptions are caught by the TDataSetAdapter and displayed on the page by the TAdapterErrorList.   When running a web application from the Delphi, the exceptions may be reported by Delphi.  To disable exception reporting, uncheck Tools/Debugger Options/Language Exceptions/Stop on Delphi Exceptions.

Grid Errors

Form Errors

Run the Application

If you haven't followed the instructions for configuring Delphi then see <%=Pages.ConfigureDelphi.Title%>

If you haven't following the instructions for configuring the Web App Debugger then see <%=Pages.TestSvr.Title%>

Run/Run

You will see a form displayed.  Web App Debugger executables are COM servers.  This is the console window of the COM server.  

The first time that your project is run, it will register the COM object that can be accessed directly by the Web App Debugger.

Start webappdbg.exe.

Click on the default URL link to display the serverinfo.exe page. serverinfo should display the name of your application.

Select on the progid of your application and click Go to display the default page.