说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

Delphi 4 WebBroker

HTML文档下载 WORD文档下载 PDF文档下载
Delphi 4 WebBroker

Borland Delphi 4 Client/Server Suite contains WebBroker technology

also called Web Modules - a set of Wizards and Components to create CGI

WinCGI or ISAPI/NSAPI web server applications. This article will cover some of the main Delphi 4 C/S specific enhancements to these Web Modules. ——Web Modules一系列的构件来创建诸如CGI

WINGI或者ISAPI/NSAPI Web Server应用程序

DB Web Application Wizard

Delphi 3 C/S offered us just one Wizard to start a new Web Module project

but with Delphi 4 C/S we can also create a new Database Web Module Application with the DB Web Application Wizard (to be found in the File | New Repository in the Business page):

(1)选择Web Module应用程序的类型CGI

WinCGI or ISAPI/NSAPI

(2)选择所使用的数据表

Once we start the Database Web Application Wizard

we can specify the type of Web Module Application (ISAPI/NSAPI is the default choice)

and the DataSet option - using a TTable or a TQuery component. Note that no matter which component we pick (Table or Query)

we'll always end up with a TDataSetTableProducer connected to this DataSet.

The Database Web Application Wizard resembles the "normal" Database Form Wizard

with the exception that we cannot create a Master-Detail Web Module Application (we only get a single Table or Query).——Wizard类似与一般的Database Wizard

只是不能创建主-从 Web Module应用程序。 Once we specified the Alias and Table

and selected the Fields that we want to see

we get to the fourth page of the Database Web Application Wizard which is Web Module specific:

(1) The options that we specify at this page will end up as property values of the TDataSetTableProducer in the Web Module that gets created upon completion of the Wizard.——在本页设置的参数将会是TDataSetTableProducer的属性。

(2)The generated Web Module contains a TTable (or TQuery) component

a TDataSetTableProducer component

and a TSession component (with AutoSessionName set to True).

IntraBob

The final page of the Database Web Application Wizard mentions the fact that - in order to test and debug a Web Module Application - one needs a Web Server and Web Browser. Fortunately

visitors of my website know this is not necessarily the case

as IntraBob v3.01 is often good enough to test Web Module Applications without needing anything else (except for Delphi

that is).

In fact

using IntraBob v3.01 to debug ISAPI/NSAPI Web Module DLLs

we should specify IntraBob as hosting application (using Run | Parameters)

and make sure IntraBob is in the same directory as the ISAPI DLL to debug. We may have to write a sample CGI HTML Form to specify the ISAPI DLL

but usually we can use a skeleton(骨架) like the CGI HTML Form below:

Where "project1.dll" is the actual name of the ISAPI DLL we want to debug. Of course

if we need to use any CGI input variables

we should add these to the above CGI HTML Form as well.

After we've done this

we can set some breakpoints in the ISAPI DLL and hit F9 to start to run (and debug). First

IntraBob (the hosting application) will be started

showing an empty page with a "Submit" button. If we click on the Submit button

the ISAPI DLL gets loaded

the entry points are obtained

and the Web Module Application is started (by triggering the appropriate PathInfo action

etc). This may end up in a breakpoint that we've set. At that particular location

we can use another great feature of Delphi: ToolTip Evaluation

which will show the contents of variables and fields (note: it doesn't work within a "with" statement

so in the screenshot below

we can't see the value of "DataSet"

as it's actually "DataSetPageProducer1.DataSet"):

Note that the above screenshot also shows the new IDE features on the left pane (Published part of TWebModule1

Variables/Constants in the unit

and the Uses clause).

The new DB Web Application Wizard is a nice addition to Delphi 4 C/S Web Module. However

I do miss the feature to create a Master-Detail relationship (I'm about to write my own Wizard to support this as well)

and I also fear that the TDataSetTableProducer is not always the most suited component for the job. In fact

sometimes I would really want to use another new addition... the TDataSetPageProducer!

TDataSetPageProducer

The TDataSetPageProducer component is a mix between the TPageProducer (with invisible HTML #-Tags that get replaced by dynamic values) and the TQueryTableProducer (that can connect parameter names with CGI HTML variable names).

A TDataSetPageProducer can contain a HTML "template"

just like a TPageProducer

where we can use tags that only need to consist of the name of a field from the connect DataSet to replace these tags by the actual value of these fields. So

if a field is named "Length"

then we need to put a tag "<#Length>" on the HTML template of the TDataSetPageProducer to make sure the tag is replaced by the actual value of the "Length" field of the current record in the DataSet. Quite helpful if you want to produce data-aware webpages

but don't want to produce Table-like output with the TDataSetTableProducer or the TQueryTableProducer.

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘