IntraWeb Manual
IntraWeb Manual
All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or
mechanical, including photocopying, recording, taping, or information storage and retrieval systems - without the
written permission of the publisher.
Products that are referred to in this document may be either trademarks and/or registered trademarks of the
respective owners. The publisher and the author make no claim to these trademarks.
While every precaution has been taken in the preparation of this document, the publisher and the author assume no
responsibility for errors or omissions, or for damages resulting from the use of information contained in this document
or from the use of programs and source code that may accompany it. In no event shall the publisher and the author be
liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or
indirectly by this document.
I IntraWeb Manual
Table of Contents
Foreword 1
Part I Welcome 3
1 Other Documentation
................................................................................................................................... 3
2 How IntraWeb...................................................................................................................................
Works 3
3 Limitations of...................................................................................................................................
the Evaluation Version 3
4 Technical Support
................................................................................................................................... 4
5 License ................................................................................................................................... 4
6 Credits, Acknowledgements
...................................................................................................................................
and Copyrights 5
7 Requirements................................................................................................................................... 6
Overview ... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ................ 6
Supported Browsers
... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ................ 7
Development Environments
... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ................ 8
Part IV Installation 16
1 Installation of
...................................................................................................................................
License Keys 16
2 IntraWeb for...................................................................................................................................
Windows 16
Uninstallation. ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 16
Installation . ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 16
3 Installing IntraWeb
...................................................................................................................................
for Linux 16
4 Upgrading to...................................................................................................................................
a new version 16
Delphi 7 Users
. ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 16
Part V Demos 19
1 Quick Start ................................................................................................................................... 19
2 Features ................................................................................................................................... 19
3 Guess ................................................................................................................................... 19
4 GuessWB ................................................................................................................................... 19
5 GuessMulti ................................................................................................................................... 19
6 FishFact ................................................................................................................................... 19
7 FishFactDM ................................................................................................................................... 19
8 Phoenitics Customer
...................................................................................................................................
Profiler 20
9 StandAloneSSL
................................................................................................................................... 20
10 WebSnapSurvey
................................................................................................................................... 20
11 Custom StandAlone
................................................................................................................................... 20
12 Back Button................................................................................................................................... 20
13 Page Forms ................................................................................................................................... 20
14 FishMarket ................................................................................................................................... 20
Part VI Debugging 22
1 Getting Started
................................................................................................................................... 22
2 Debug Output
................................................................................................................................... 22
3 Detecting Errors
...................................................................................................................................
on Startup 22
4 Command Line
...................................................................................................................................
Parameters 22
1 WebApplication
...................................................................................................................................
Object 43
2 Referencing ...................................................................................................................................
the Session 43
3 Lifetime ................................................................................................................................... 43
4 Implementation
................................................................................................................................... 43
5 Storing Additional
...................................................................................................................................
Data 44
6 Session Related
...................................................................................................................................
Events 44
7 Memory Consumption
................................................................................................................................... 44
8 Component Reference
................................................................................................................................... 45
9 How does Session
...................................................................................................................................
Management Work? 45
URL . ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 45
Cookies . ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 46
Hidden Fields. ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 46
3 IntraWeb and...................................................................................................................................
Websnap 66
Creating the Demo
. ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 67
Running the Demo
. ... .... ... .... ... .... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... .... .... ... .... ... .... ... .... ... ............... 73
Index 0
I
3 IntraWeb Manual
1 Welcome
IntraWeb is a revolutionary new way to create web-based applications. Built upon Web Solution Builder
and earlier versions of IntraWeb, it extends the technology of both of these, providing an excellent tool
for creating Internet, Intranet and Extranet applications in a quick and easy to maintain manner.
Many web-based development tools require the user to have knowledge of CGI scripting, state tracking
and complex client configurations. IntraWeb does away with all these hassles and overheads. By
simply creating the application using the component suite within Delphi, and later registering it on the
server, clients can access the application using any browser that complies with HTML version 4. These
include the latest versions of Netscape and Internet Explorer. Both of these have been fully tested with
IntraWeb and are 100% compatible. No HTML, CGI or JavaScript coding is required; all the coding is
done using Delphi. For further flexibility, the application can also be run as a stand-alone executable
like any other Desktop application, providing debugging capabilities.
This document is designed to be a manual, not a reference guide. The IntraWeb Component
Reference help file should be consulted when a reference for properties, events, methods and
components is needed.
IntraWeb is designed to build any sort of web-based application, whether it is a simple data entry form,
a poll, or a complex application where clients have to be "logged in" for an extended period of time.
IP Restriction
In the evaluation version, IntraWeb applications only listen on the IP 127.0.0.1. No requests from other
IP addresses will be answered.
No Services
IntraWeb applications cannot be installed or run as services in the evaluation version. Attempts to do
so will result in errors.
No SSL
SSL is disabled in the evaluation version.
No Deployment License
You may not deploy any applications created with the evaluation version.
1.5 License
Single User License agreement
This is a legal agreement between you the end user, and Atozed Software (hereafter referred to simply
as Atozed). By using this software package you are agreeing to be bound by the terms of this
agreement. If you do not agree with the terms of this agreement, promptly uninstall this software.
Grant of License - Atozed grants to you the right to use one copy of the enclosed software for a
single developers use. This includes the ability to install on multiple computers so long as the
installation is only used by the same single developer. In plain english this means you can
install this software on your desktop and your laptop so long as you are the only one who uses
the software. You may not install on multiple computers for multiple developers to use.
Furthermore you may not install on one computer for multiple developers to use aside from
normal debugging purposes and peer review.
You may make one copy of the software for backup purposes for use on your own computer.
The original software must be backed up in unmodified form.
You may not network the woftware or use it on more than a single computer or computer
terminal at any time, unless a copy is purchased for each developer on the network that will
use the woftware. You may not rent or lease the software, but you may transfer the software
and accompanying written material and this license to another person on a permanent basis
provided you retain no copies and the other person agrees to accept the terms and conditions
of this agreement.
THIS SOFTWARE MAY NOT BE DISTRIBUTED, IN MODIFIED OR UNMODIFIED FORM, AS
PART OF ANY APPLICATION PROGRAM OR OTHER SOFTWARE THAT IS A LIBRARY-
TYPE PRODUCT, DEVELOPMENT TOOL OR OPERATING SYSTEM, OR THAT MAY BE
COMPETITIVE WITH OR USED IN LIEU OF THE PROGRAM PRODUCT, WITHOUT THE
EXPRESS WRITTEN PERMISSION OF Atozed.
This license does include the right to distribute applications using the enclosed software
provided the above requirements are met.
Term - This agreement is effective until you terminate it by destroying the software, all copies and
backups. It will also terminate if you fail to follow this agreement. You agree upon termination
to destroy the software, together with all copies thereof including backups.
Copyright - The software is owned by Atozed and is protected by International laws and treaties.
Therefore, you must treat the software like any other copyrighted material.
Warranty Clause
Limited Warranty - Atozed warrants that the software will perform substantially in accordance with
the accompanying written materials. Atozed does not warrant that the functions contained in
the software will meet your requirements, or any operation of the software will be uninterrupted
or free of errors.
Disclaimer of Warranties - Atozed disclaims all other warranties, either expressed or implied,
including but not limited to implied warranties of merchantability of fitness from particular
purpose, with respect to the software and accompanying written materials. Atozed will have no
consequential damages. In no event, shall Atozed or its suppliers be liable for damages
whatsoever, (including without limitation, damages for loss of business profits, business
interruption, loss of business information, or any pecuniary loss), arising out of the use or the
inability to this product, even if Atozed has been advised of the possibility of such damages.
U.S. Government Restricted Rights - This software and documentation are provided with
restrictive rights. Use, duplication or disclosure by the Government is subject to restrictions set
forth in Section c(1)(ii) of the Rights and Technical Data in Computer software clause at
52.227-7013.
IntraWeb
IntraWeb is a commercial product and fully protected by International copyright laws and treaties.
Doc-O-Matic
Doc-O-Matic 1.1 is used to build the IntraWeb Component Reference help file.
http://www.doc-o-matic.com
Inno Setup
The IntraWeb installation is performed using Inno Setup which is Copyright © 1998-2001 Jordan
Russell with portions by Martijn Laan.
Indy
IntraWeb uses Indy to provide much of its functionality. Indy requires that its copyright be included.
Please note that this copyright only applies to the Indy code itself. More information on the licensing of
Indy can be found at http://www.nevrona.com/indy/license.html.
Copyright
Portions of this software are Copyright (c) 1993 - 2001, Chad Z. Hower (Kudzu) and the Indy Pit Crew -
http://www.nevrona.com/Indy/
License
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation, about box and/or other materials provided with the
distribution.
No personal names or organizations names associated with the Indy project may be used to endorse
or promote products derived from this software without specific prior written permission of the specific
individual or organization.
THIS SOFTWARE IS PROVIDED BY Chad Z. Hower (Kudzu) and the Indy Pit Crew "AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jason Southwell
For contribution of several components and starter components.
Thomas Brattli
http://www.dhtmlcentral.com
For eXperience DHTML coolMenus which are the basis for TIWMainMenu.
Motty Adler
For contribution of the idea and the source that TIWTimer is based on.
Others
Thanks to all the other parties who have assisted with both small and large contributions that we may
have overlooked.
1.7 Requirements
1.7.1 Overview
The only requirement is that users of IntraWeb developed applications have browsers that are HTML 4
compatible *, since extensive use of HTML 4 and JavaScript are made. IntraWeb has been
extensively tested with Netscape and Internet Explorer and is supported with Mozilla, Netscape 6 and
higher and Internet Explorer 4.0 and higher.
NOTE: If you want Netscape 4 support you should use IntraWeb version 4. Which we will continue to
maintain and support. As of version 5.1, IntraWeb supports HTML 3.2 in PDA version. Therefore,
HTML 4
IntraWeb uses HTML 4 and style sheets to achieve the coordinate placement of items and other
features. Usage of templates or page mode can eliminate the need for style sheets.
JavaScript
JavaScript is used to allow many advanced client features. JavaScript also allows IntraWeb to control
the browser and rendered pages. JavaScript is only required for Application Mode.
Browser Implementations
Even with HTML and JavaScript standards in place, the browsers differ in many areas. Much of this is
because browsers often make extensions before such features are adopted as standards. Often
different browsers implement similar features in incompatible ways.
IntraWeb adjusts for these differences automatically. IntraWeb generates the appropriate HTML and
JavaScript code for the browser. IntraWeb even knows about certain bugs in specific versions of each
browser and works around them dynamically. In other cases, output for each browser is optimized.
IntraWeb performs all of this transparently to you and without using Java, ActiveX, or any plug-ins.
Internet Explorer
Internet Explorer versions 4, 5, and 6 are supported.
Netscape 6
Netscape 6 is supported. There are some known issues with Netscape 6 which are fixed in the recent
GECKO engine used in Mozilla 1.0 RC1.
Mozilla
Mozilla is supported.
Opera
Due to the amount of restrictions Opera 6 has with support for JavaScript, certain characteristics are
not supported currently in Opera. Many of these have to do with Anchors and alignment. Left and Top
positioning is supported with anchors, however, currently Right and Bottom are not. Work is being
done to provide full support for Opera with the next versions of Opera and IW. Other functionality IS
supported in Opera.
There is also a Java edition that supports JBuilder, which is sold as a seperate product
II
What's New 10
2 What's New
2.1 Overview
IntraWeb 5.1 introduces new features and enhancements in the following areas:
III
Migration Guide 12
3 Migration Guide
3.1 Overview
Whenever possible interfaces have remained the same. However is some situations it was deemed
better to change interfaces for future expansion.
For the most part migrating from a 5.0 application to 5.1 is straightforward and this section is designed
to assist you with this migration.
TIWImage
The UseBorder property has been deprecated. The new BorderOptions property should be used
instead.
RWebApplication
RWebApplication is now simply WebApplication. Scope determines whether this threadvar version or
the property version is accessed.
Project Files
The project files have a new format and standalone debug executables are now seperate projects from
the standalone service executables. Examples of each can be seen by looking at the Guess demo.
program Guess;
uses
Forms,
IWMain,
Main in 'Main.pas' {formMain: TIWFormModuleBase},
ServerController in 'ServerController.pas' {IWServerController:
TDataModule};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TFormIWMain, formIWMain);
Application.Run;
end.
When converting Service applications, you need to add IWInitService to the uses clause of the DPR
and replace the existing code with:
program GuessService;
uses
IWInitService,
Main in 'Main.pas' {formMain: TIWFormModuleBase},
ServerController in 'ServerController.pas' {IWServerController:
TDataModule};
{$R *.res}
begin
IWRun;
end.
ISAPI and DSO projects have the following layout (DPR file):
library GuessDLL;
uses
IWInitISAPI,
Main in 'Main.pas' {formMain: TIWFormModuleBase},
ServerController in 'ServerController.pas' {IWServerController:
TDataModule};
{$R *.RES}
begin
IWRun;
end.
library GuessDSO;
uses
ApacheApp,
IWInitApache,
ServerController in 'ServerController.pas' {IWServerController:
TIWServerControllerBase},
Main in 'Main.pas' {formMain: TIWFormModuleBase};
{$R *.res}
exports
apache_module name 'GuessDSO_module';
begin
IWRun;
end.
When compiling for Apache 2, you need to make sure that you include IWInitApacheTwo in the uses
as opposed to IWInitApache. If you create an Apache 2 application using the wizard, this is automatic.
NOTE: You need to make the appropriate changes to the Delphi 7 VCL before your modules will work
with Apache 2. This information can be obtained on the Borland Community Site.
initialization
TformMain.SetAsMainForm;
SetAsMainForm is a class procedure of a TIWForm. When working on projects that support both
HTML 4.0 and PDA (HTML 3.2), it is VERY IMPORTANT that both the main form for the 4.0 version
and the 3.2 version each have an initialization section indicating that it is the main form (see
GuessMulti for examples).
The other initialization section is in regard to the server controller. This has to be set in the
ServerController itself and it present for new projects:
initialization
TIWServerController.SetServerControllerClass;
OnNewSession
The OnNewSession event handler has a change in the signature. The new signature is:
Be sure to include IWBaseForm and IWBaseControl in the uses of the ServerController if converting
from a previous version.
TemplateProcessor property
This property has been renamed to LayoutMgr. Assign any TemplateProcessor components on your
form to this
new property
IV
Installation 16
4 Installation
4.2.2 Installation
The installation will automatically integrate IntraWeb into Delphi. Three new tabs will be created on the
component palette containing the IntraWeb components. One of them contains the non-database
components, another contains the data-aware ones, and the third contains control components. A new
tab will also be created in the Delphi repository. All IntraWeb applications should be created using the
templates contained in the repository under the tab IntraWeb.
The installation process copies the appropriate files to the Windows\System directory and to sub
folders of all the Delphi environments selected. It also creates program group, which can be accessed
via the Start menu. The documentation is placed in this program group.
V
19 IntraWeb Manual
5 Demos
Many of the demos have multiple project files such as Features / FeaturesDLL / FeaturesDSO.
Features is the standalone version, FeaturesDLL is the ISAPI version, and FeaturesDSO is the Apache
version. They are different project files but share the same units and aside from the project file the
source code is identical.
Finally you can finish up with the "Features" demo which is not a "functional" application per se but a
demo that demonstrates many of the features of IntraWeb merely to demonstrate them.
There are also additional user contributed source and demos available from the IntraWeb download
page on the Atozed website.
5.2 Features
The Features demo is not designed as a functional application. It is designed as a demo to show off
specific features of IntraWeb. Use this demo to see how to use specific features in IntraWeb but also
to see some of the things that IntraWeb can do.
5.3 Guess
Guess is a very simple application and contains only one form. It is however the ideal starter demo to
understand how IntraWeb works. The demo serves as a simple guess the number game.
5.4 GuessWB
GuessWB is the Guess application implemented using page mode instead of application
mode.
5.5 GuessMulti
GuessMulti is a demo which simultaneously supports normal browsers as well as PDA's in a single
executable.
5.6 FishFact
FishFact is an IntraWeb port of the popular Delphi Demo FishFact. This demo requires DBDemos.
5.7 FishFactDM
FishFactDM is the same as the FishFact demo, but demonstrates how to use Datamodules with
IntraWeb. FishFactDM also shows how to present a paged grid. This demo requires DBDemos.
5.9 StandAloneSSL
StandAloneSSL demonstrates the use of stand alone mode with an SSL connection using sample
certificates.
5.10 WebSnapSurvey
WebSnap survey shows how to use IntraWeb page mode with WebSnap. This demo only works in
Delphi 6 Enterprise and higher as WebSnap is new to Delphi 6 and only included in Delphi Enterprise.
5.14 FishMarket
FishMarket demonstrates how to use Re-Entry command in combination with cookie tracking to allow
you to exit and re-enter an IW application by passing parameters on the URL.
VI
Debugging 22
6 Debugging
This is a screenshot with the debug tool bar button depressed, and debug output information from one
user session:
Auto Minimize
The debug screen can be told to start minimized by passing /minimize on the command line. This is
useful during development if combined with /LaunchBrowser
VII
25 IntraWeb Manual
7 Development
One example of this is DBGrids. In a normal Delphi application, it might be considered normal to
display hundreds or thousands of records in a grid. Doing such on the web will create very large HTML
documents and very slow load times for the user.
Once developers realize this fact, they often ask for "Next" and "Previous" buttons and that the DBGrid
be expanded to allow partial display. While this could be implemented, it would need to be
implemented either to consume large amounts of memory on the server, or by constantly requiring the
database which would consume less memory but would be slow. Instead of approaching it like a
normal Delphi application, rethink your interface for the web.
Certainly not the only possibility, but a common one is the following technique. Instead of presenting
your users with thousands of records initially, present them with a blank grid and a search field.
Require your users to present some basic criteria to locate the records that they need. Using the
search criteria, you can then return dozens, or just a few hundred rows. Not only is this good for
bandwidth, but it is a good user interface, and will minimize the load on your database.
Allowing users to enter search criteria still allows for the possibility that the results may still number in
the thousands and cause the very same problem that you were trying to avoid. To assist with this,
TIWDBGrid has a RowLimit property. It defaults to 0, which means it is disabled. You can set it to a
maximum value, and no matter how may rows the query returns, no more than the number in RowLimit
will be returned to the user.
If you think about this, you have probably seen this technique elsewhere. Many search engines limit the
number of rows that are returned. This is not only for bandwidth reasons. In most cases, the data
becomes diminishingly useful after a certain number. In cases where this is not true, simply too much
data is given to the user at one time and they will likely filter it anyways.
If you still decide that you do want a "paged grid" consisting of small sets of data with next / previous
options you can accomplish this by setting the TIWDBGrid's StartFirst property to false and setting the
RowLimit property to the number of rows you wish to display at a given time. Then by positioning the
dataset before display, you can move next / previous.
This creates a framework for a new IntraWeb stand alone application. Although the project can be
compiled and executed at this stage, it does not do anything. The standard debug form comes up
displaying some information about IW and menu items to debug the application. Selecting the Execute
(or pressing the F9 key) menu item will launch the browser with a blank page. This is because main
form does not contain any components or functionality yet.
program Project1;
uses
Forms,
IWMain,
ServerController in 'ServerController.pas' {IWServerController:
TIWServerController},
Unit1 in 'Unit1.pas' {IWForm1: TIWFormModuleBase};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TFormIWMain, formIWMain);
Application.Run;
end.
The code in the figure above displays the contents of the project file. You can see that it is the same as
a standard Delphi application. This is true for stand alone applications.
As mentioned previously, the new project is the basic building block for any IntraWeb application. Like
any other Delphi project, a main IntraWeb form is created and can be used as the main form of the
application. To demonstrate the power and the facility of IW applications, below, a small example is
shown.
Once the steps are complete, compile and run the application. To test it, press the F9 key. The default
browser should be launched and display the main form. Enter some text in the text box and click on the
button. The output is displayed in the label.
Granted what we have shown in this example is not rocket science. But, it has been created using
standard Delphi code and without any HTML. The example presented has been chosen because of its
simplicity. The purpose is to demonstrate that programming IntraWeb applications is very much the
same as developing any other Delphi application. The same methods, properties, events, etc can be
used in the same way. However, IntraWeb is much more powerful and can be used to create fully
enabled database applications and more.
For a more detailed introduction to creating new applications and detailed tutorials, please see tutorials
on the Atozed website at http://www.atozedsoftware.com.
Templates
Use of graphics in templates is done by inserting the graphics directly into the HTML. Graphics may be
served using the Files directory, or a standard web server.
TIWImage
TIWImage is used for dynamic images. Each time an image is requested the image is converted to a
JPG. This can be rather resource intensive and thus should only be used for images that will be
For an example of this, please see the Dynamic Interactive Image demonstration in the Features
demo.
For static images that are not generated each time, use TIWImageFile.
TIWDBImage
TIWDBImage converts images from a database field to a JPG automatically. It is used just like a
normal TDBImage, it performs all the work necessary to display the image from the database field into
the browser.
For an example of TIWDBImage, see either of the FishFact demos.
TIWImageFile
TIWImage file serves a file directly from a file on disk. Because it does no conversion of the image,
TIWImageFile is an extremely efficient way to serve images and is much more efficient than
TIWImage. If you are using images that are completely static, you should always use
TIWImageFile .
TIWImageFile provides for design time support as well by displaying the image at design time.
However the image is merely displayed, the image data is not stored with the form. Whenever
displayed at design time the image is loaded from the file on disk.
The filename specifies a full path and filename to the image file to display at design time.
At run time, the path is ignored and only the filename is used. At run time, the image is expected to be
in the files directory.
GIF Support
IntraWeb can support GIF files however the install does not install GIF support. Please see the
IntraWeb FAQ for details on how to use GIF files with IntraWeb.
For further information on creating custom components please see the section "Writing Custom
Components" in this manual.
HTML Templates
HTML templates (simply referred to as templates elsewhere) can be used to add advanced HTML into
your application and customize the look of your application. Please see the section on layout managers
for more details.
Uninitialization is also taken care of automatically when the property is set to something other than
ciNone.
The reason for the access violation is that if DBClient is not included in project file uses
clause, it's internal interfaces are freed before all sessions are closed and when IW closes it's
sessions it will try to free ClientDataSet component, and you will get the access violation.
When DBClient is placed before IWMain IW will free sessions before DBClient interfaces are
freed.
7.7 Working with PDA
IntraWeb 5.1 introduces support for PDA. This is accomplished by restricting the output generated by
IW application using pure HTML 3.2 without any additional JavaScript or Cascading Style Sheets.
Although at first this would seem that application development is limited, it is important to understand
that the limitations are mostly imposed by the devices rather than IW. Since HTML 3.2 is a standard
that nearly all devices on the market support, it is a good option for developing web applications
focused on PDA's.
important to remember that when using an external editor to design 3.2 forms, you need to restrict the
HTML elements to 3.2 standard. Most HTML editors allow you to set this option before editing.
1. Using the Standalone application, click on the PDA icon before launching the browser with the
Launch Browser button.
2. Directly type the URL in the browser appending 32 at the end, e.g. http://127.0.0.1:8888/32
This will allow you to see the results of your IW PDA application on the browser.
When using the application directly from a PDA device, IW will detect the browser that the PDA device
uses and automatically launch the PDA application.
7.8 Miscellaneous
External Files
Files such as images and download can be accessed using relative paths located under the main
application folder. Create a folder named files and place all HTML objects referenced inside it. In the
HTML page you can reference the images using:
img src="../files/image.jpg"
Be sure to use / and not \. Internet Explorer will correct for \, but other browsers will show broken
images. In addition, this functionality is not limited to images and can be used for any file type.
Files accessed with the files URL are cached by the browser. If you wish to create dynamic files that
should not be cached use ../filesnc/<filename> instead of ../files/<filename>. Files will still be retrieved
from the same place in the files subdirectory, but the browser will be instructed not to cache them.
Server Controller
Each application has a ServerController unit. The ServerController contains properties to affect how
the application acts and behaves on a global scale. It also contains events that can be defined. For
more information, see the Server Controller chapter.
Datamodules
If you use datamodules, please see the FishfactDM demo. One thing to note, if you link your
datasource properties to a datamodule at design time like FishFactDM does, your datamodules MUST
be owned by the users WebApplication. This is done in FishFactDM by setting the datamodule's owner
to the session data's owner, which is the WebApplication variable. If this is not done, the forms will not
be read in properly and all the forms will be linked to the first and same datamodule.
VIII
31 IntraWeb Manual
8 Form Management
8.2 TFrame
Use of Delphi's TFrame is supported. For information on TFrame usage, please consult the Delphi
help.
An example of TFrame usage with IntraWeb can be seen in the Features demo.
You can however use code inheritance. Code inheritance allows inheritance of methods, members and
properties. You can also create controls dynamically.
1. Only one form may be visible at any time. This is because the form is actually shown in the
browser.
2. Modal forms may not be used, however since only one form at a time may be visible, essentially
all forms are modal.
3. Forms must be owned by WebApplication.
Normally the form list is never directly interacted with by the user but instead methods of the forms are
called. However there are cases where direct interaction with the form list may be necessary. For these
cases TIWApplication contains several methods for interacting with the form list and are documented
in the help file.
TFormType.Create(WebApplication).Show;
This should be familiar to you as it is the same as in a standard application except the owner
here is WebApplication. One thing that is different however is that in a normal application the
form is shown immediately when the .Show method is called. With an IntraWeb application
the call to the .Show method merely sets the form as the next active form to show after the
event exits and returns to IntraWeb. Only after the event executes will the form be shown.
A given instance of a form can be shown multiple times to bring it to the top. In this case the
instance of the form will be in the form list in multiple places.
8.7 Hiding Forms
In a normal application a form can be hidden without destroying the form by calling the .Hide
method.
The same functionality can be implemented in IntraWeb by calling its simply calling the .Hide
method. The .Hide method will hide the form without destroying it as .Release does.
.Hide removes all references in the form list as .Release does but does not destroy the form.
Because of this you must keep a reference to the form if you wish to redisplay it later,
otherwise the form will become orphaned.
8.8 Destroying Forms
In a normal application when a form is no longer needed it can be destroyed using the .Free or
the .Destroy methods.
In an IntraWeb application it is similar, however you must not call the .Free or .Destroy
methods directly. Instead you must call the .Release method. The .Release method does not
actually destroy the form when called. The form will not be destroyed until the event exits and
returns control to IntraWeb. This is because .Release is usually called from within and event
of the form itself, although this is not always the case.
After release is called, just like in a normal application the active form becomes the one that
was active prior to the destroyed form became active. If you do not wish to return the user to
the prior form you must call the .Show method for a different form.
The .Show method can be called before or after .Release since neither takes effect until
control is returned back to IntraWeb.
When a form is released, all references to it in the form list are removed. This causes an
alteration in the order of the forms that will be shown when forms are hidden or released with
no explicit .Show method calls.
8.9 Passing Data Between Forms
Data can be passed between form just like in any normal application. Since forms are
persistent information can be stored in member variables of form classes.
For demonstration purposes we will define two forms, TFormMain and TFormDialog.
TFormMain is the main form and contains an button and an edit box. TFormDialog contains a
memo field and a label.
When the user presses the button on the first form the text from the edit box will be added to
the memo on the dialog form and the form will be displayed. The dialog form will also display
how many times it has been displayed and allow the user to return to the main form.
unit Main;
{PUBDIST}
interface
uses
IWAppForm, IWApplication, IWTypes, IWCompButton, IWCompEdit,
Classes,
Controls, IWControl, IWCompLabel, Dialog, IWHTMLControls;
type
TformMain = class(TIWAppForm)
IWLabel1: TIWLabel;
editText: TIWEdit;
butnOk: TIWButton;
IWLink1: TIWLink;
procedure butnOkClick(Sender: TObject);
procedure IWAppFormCreate(Sender: TObject);
procedure IWLink1Click(Sender: TObject);
public
FDialogForm: TformDialog;
end;
implementation
{$R *.dfm}
uses
SysUtils;
end.
IWLink1 OnClick
This event is hooked to the link with the caption "Quit" and simply terminates the user session
when the user clicks the link.
OnCreate
The OnCreate event is called when the form is created. In this event another form is created
and the reference to it is stored as a member variable of this form so it can be accessed again
later.
butnOk.OnClick
In the OnClick event the edit box is checked for data. If no data exists
WebApplication.ShowMessage is called to display a message to the user. After the message is
dismissed the main form is shown again.
If the user did enter data, using FDialogForm (which was created in this form's OnCreate) is
used. Data is added to the memo, and a member variable of TFormDialog is updated. It is then
displayed using the .Show method. As you can see, data is very easy to pass between forms
Complete Demo
To see the project in action, please see the FormData.dpr project in the Demos directory.
IX
37 IntraWeb Manual
9 State Management
9.2 Restrictions
Global Variables
Global variables in general should not be used. If you want to use a global variable that is
"global" yet specific to each user session you need use variables that are tied to the user
session as described later.
If however you want a variable that is global among all user sessions you can and should in
fact use a global variable. However as IntraWeb is a threaded environment you must take the
proper steps to protect the variable from concurrent access.
ThreadVars
ThreadVars should never be used in an IntraWeb application except as temporary storage
under controlled circumstances. IntraWeb is based on HTTP which is stateless. This
essentially means that threads are not assigned to a specific user and a user is moved between
threads between HTTP requests.
User Session
The user session (covered more in detail in the Session Management section of this manual)
contains a .Data property that can hold a reference to an object. When you need to store user
specific information you can store it in the .Data property of the session. Data accepts a
TObject instance and will destroy the TObject automatically when the session is destroyed.
The easiest way is to create an object and add the fields that you wish, and then create your
object and store it in the session's Data property when the session is created. The Phonetics
demo shows an extended example of this.
When a new IntraWeb project is created a shell user session object is created for you in the
ServerController. The default ServerController looks like this:
unit ServerController;
{PUBDIST}
interface
uses
SysUtils, Classes, IWServerControllerBase,
IWApplication, IWAppForm;
type
TIWServerController = class(TIWServerControllerBase)
procedure IWServerControllerBaseNewSession(ASession:
TIWApplication;
var VMainForm: TIWAppForm);
private
public
end;
TUserSession = class
public
end;
// Procs
function UserSession: TUserSession;
implementation
{$R *.dfm}
uses
IWInit;
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWAppForm);
begin
ASession.Data := TUserSession.Create;
end;
end.
TUserSession is an empty session object that you can add members, properties and methods
to. The code to create the TUserSession for each session is also created in the OnNewSession
Event.
A function named UserSession also exists for easy access to the object. So if you changed the
TUserSession declaration to the following:
TUserSession = class
public
Username: string;
Password: string;
end;
You could access these properties elsewhere in your code simply as shown here:
UserSession.Username := 'Joe';
LPassword := UserSession.Password;
If you do not need a user session you may choose to eliminate it from the code. It is not
necessary and is part of the default template simply as a convenience.
The class type of TUserSession can be of any type. For projects that are generated with a
datamodule the TUserSession is a descendant of TComponent and not TObject as shown here.
TComponent allows the session to own components such as the datamodule and allows for
easier cleanup.
•Stateless – They are completely stateless and reconstruct state between each page. This is
usually very inefficient on the server side for weblications and puts considerably extra load
on databases because data is read and written unnecessarily.
•State Streaming – These types stream the state into and out of each web page. This
consumes bandwidth and slows down page accesses. They also cannot use complex data,
or usage of complex data causes the same problems described prior.
Even applications that support the back button, such problems are still encountered. However
because they allow old data to be posted they must check the data to see if the requested
operations can be performed. This adds significantly to the amount of user code except in the
simplest of systems. Such systems are typically not weblications, but individual dynamic
pages.
After this warning is shown, the user will be shown the current form as it was before they
used the back button.
This functionality can be turned on by setting the .HistoryEnabled property to true in the
server controller.
This warning dialog can also be turned off. To do so set the .ShowResyncWarning property to
false in the server controller. If false, instead of seeing the warning dialog the user will simply
be resynchronized with the current form.
OnBackButton is fired when a form is re-submitted to the server. The event can therefore be used to
detect what operation needs to take place if old data is re-sent. Assigning the event effects two
properties: HistoryEnabled and ShowResyncWarning. When an event has been assigned, the first
property is automatically set to True whereas the latter is set to False.
IntraWeb works in sequences. Each form that is submitted carries a sequence number with it. When
the application is first started, the sequence (or track ID) is set to 0. Everytime a form is submitted, this
track ID is incremented by 1. Sequences play an important role in back button events.
· ASubmittedSequence: Represents the sequence that has been submitted. This will always be
LOWER than the ACurrentSequence that represents the current sequence.
· ACurrentSequence: Represents the current Track ID.
· AFormName: Working with sequence numbers, although powerful can become cumbersome.
Alternatively, you can use the AFormName parameter to see WHICH form has been re-submitted.
· VHandled: When controlling a re-submitted form, you need to set the VHandled property to True,
otherwise IntraWeb will understand that the event has not been handled and will display the default
action which is to show the Re-sync message.
· VExecute: When a form is re-created in the OnBackButton event, you can choose whether you want
to execute it or generate it. By default VExecute is FALSE which means that the form will be
generated.
For more information and an example of using the OnBackButton take a look at the BackButton
demo located in the application folder.
X
43 IntraWeb Manual
10 Session Management
WebApplication ThreadVar
In code that is not contained inside of an IntraWeb form or component, the threadvar version can be
accessed. This is especially useful in global procedures, or in TFrame code.
10.3 Lifetime
A users session is automatically managed by IntraWeb. When a new session is started IntraWeb will
create a new instance of a TIWApplication for the user and track it automatically. It can then be used to
acquire information about the user, control the users session, or store additional information. No
management on the developers part is required to implement session management, or to track the
user.
A session exists until it is manually terminated by calling one of TIWApplication's terminate methods,
or a timeout occurs. If a user does not access the application within a given time period, the user's
session will be destroyed. The default timeout period is 10 minutes, but can be adjusted by changing
the SessionTimeout property in the applications ServerController.topic text here.
10.4 Implementation
Sessions are managed automatically by IntraWeb. Sessions are stored in memory on the server and
there fore are secure from users who may attempt to modify the session data.
Each session is assigned a unique session ID that is used to identify the session. The session ID is
constructed in a secure manner so that session IDs are not predictable and thus prone to hacking. In
addition each session is tied to the users browser and if another browser is detected attempting to use
the same session an error will be returned.
For further security the ServerController's RestrictIPs property. This will check the user's IP address
against the session and return an error if the IP address changes. This option is false by default and
should only be set to true in Intranets or Extranets with controlled clients. This is because some proxy
servers such as Microsofts ISA proxy server change IP addresses between HTTP requests for a given
user and will cause multiple IP addresses to be seen by the IntraWeb server.
By default the session ID is embedded in each HTML page and tracked with each HTTP request. This
allows a single user to have multiple sessions per application. The disadvantage is that once the user
is inside the application they cannot leave the application and return to it. Because of this when using
this method of session ID tracking any non application web pages must be opened in new windows
unless it is in response to the application terminating.
Session tracking can be set to use cookies instead of embedding in the HTML page by setting the
ServerController's SessionTrackingMethod property to tmCookie. This will instruct IntraWeb to use
cookies to track the user's session instead. The advantage is that the user can move in and out of the
application to other web pages with ease. The disadvantage is that many users disable cookies and
also that the user can only have one session per application.
OnNewSession
OnNewSession is fired each time a new user session is created. It passes in two arguments,
ASession and VMainForm.
ASession is a reference to the newly created session and can be used to query information
about the user or modified with custom information such as creating an object to be stored in
the .Data property.
VMainForm is passed as a var parameter. It is initialized to nil and if not set the default main
form as specified in the project file (dpr) will be used. VMainForm however can be modified
based on parameters passed on the start URL, or based on other criteria to specify a main form
for the user. To specify an alternate main form simply create it and return its instance in the
VMainForm argument.
OnCloseSession
OnCloseSession is called when a users session is about to be terminated. This occurs either
when one of the forms of WebApplication.Terminate is called, or the session has timed out
IntraWeb allows the user to specify how session management is tracked. This provides
flexibility since certain situations restrict the user to a certain type of tracking. For example,
when the application is deployed to a large corporation, which has certain browser restrictions
such as not permitting cookies, another form of session tracking can be used. To provide this
flexibility, session tracking can be obtained using one of the following options: Hidden Fields,
URL and Cookies.
Developers that are accustomed to implementing session tracking using technologies such as
WebBroker are familiar with these since they are the 3 most common (if not the only) way of
implementing such a feature. The method used is set as a property in the ServerController
(SessionTracking).
10.9.1 URL
URL session tracking is the default method. When using this method, the information appears
in the URL at all times. When the application is first called, the URL is of the form:
http://xxx.xxx.xxx.xxx:xxxx/{start_command }
After the first call, the appropriate session information will be appended to the URL, which
will be:
http://xxx.xxx.xxx.xxx:xxxx/exec_command/Z/YYYYYYYYYYYYYYY
There are two important values here to understand, Z represents the track ID whereas
YYYYYYYYYYYYY represents the session ID. The track ID represents the "state" in which the
application is. When an IW application starts, the track ID is set to 0. Every time a new
request is made to the server, the track ID is incremented by 1. Each new request has a higher
value than the previous one. This allows IW to know exactly what state it is in.
The session ID is a random value that is generated from unique values so that it is different for
each user that accesses the application. This makes it virtually impossible for sessions to be
intermixed between two users.
One of the disadvantages of using URL as session tracking is that the user will always see the
URL in this format. Any change in the session ID will result in a invalid session
message.
10.9.2 Cookies
Cookies is a good alternative when users have cookies enabled in their browser and have no
problems using them. Cookies also offer the advantage of not having a long URL and also re-
entry options. By allowing re-entry, the application can link to an external website and from
that external website link back into the application. For more information regarding this, see
the OnReEntry event in the ServerController.
As for the information stored, the same entries (session Id and track ID) as with tmURL as
stored in the cookie.
XI
Layout Managers and Templates 48
The use of templates still requires the browser to support HTML 4 and JavaScript.
Any framed controls will be rendered without frames when templates are used. If you wish to
have them frames in the template, you should frame them by using IFrame or other method in
your template.
To use templates create a 'Templates' sub directory in your application directory and create a
<FormName>.html file. Next, for the form that you wish to apply the template to:
For each component, the template should contain a tag of the form
{%Component.HTMLName%}. HTMLName in most cases is the same as the name. When
the form is generated, the tags will be replaced with the component output. The use of {%%}
instead of <> allows for easier editing in WSIWYG HTML editors and is compatible with all
HTML editors. The {% %} tag characters are also not considered special characters and
therefore are not converted to special tags. By default, a master FORM tag will surround the
body to ensure proper function of all input controls and buttons. However, in some cases this
can interfere with the HTML. For such cases, see the help topic for
TIWTemplateProcessorHTML.MasterFormTag.
For components on a TFrame, HTMLName differs from Name. Because a TFrame is the
owner of the components contained in it, components on a TFrame can have the same name as
components on other TFrame instances, or as components on the form. To circumvent this
components on a TFrame set their HTMLName to the frame name + component name at run
time. For instance, if a component named Label1 is on a TFrame named Frame1, the
components HTMLName at run time will be Frame1Label1. {%Frame1Label1%} is the tag
that need to use when using components on a frame in a template.
If you wish to use the Borland style tags <#TagName#> instead of the IntraWeb style tags you
can set the TagType property to ttBorland. IntraWeb type tags are easier to use with
WSYWIG HTML editors.
System Dialogs
There are two specific template files called IWShowMessage.html and IWException.html.
These are used to provide additional formatting to ShowMessage method and for the display
of uncaught exceptions. The following tags must be present:
{%textMessage%}
{%butnOk%}
Note that the template for ShowMessage has no effect when smAlert or smNewWindow is
passed to ShowMessage.
System Messages
System Templates support two tags: {%Content%} and {%AppName%} which can be used to
display the error message. {%AppName%} is as specified in ServerController.AppName. The
tag {%AppID%}. IT refers to the application ID.
IWError.html
System errors are errors that happen outside of your application and in the server portion of
IntraWeb. These errors are rare and usually consist of such things as the user entering invalid
requests via URLs or trying to access expired sessions. These errors can be handled by
creating a template named IWError.html.
XII
51 IntraWeb Manual
12 Server Controller
Although at first it might not seem too important, and when you create you first IW application, you
might not even open the form; the ServerController plays a very important role in an IW application.
From it, you can control properties such as the port, SSL settings, and much more. This chapter
explains the concepts of the ServerController.
* The form is ONLY created when working in APPLICATION mode with IntraWeb. When using
PageMode, the ModuleController creates a server controller internally.
12.2 Properties
Most of the relevant properties of the ServerController are published and therefore accesible via the
Object Inspector. To view these properties, choose the IWServerController form from your project
forms by hitting CTRL-F12.
For information on the properties of the ServerController, please see the IntraWeb component
reference help file.
XIII
53 IntraWeb Manual
13.1 Overview
All IntraWeb components are written using an open API that easily allows you to write your own
components and add them to IntraWeb just as you can with Delphi. To further facilitate the writing of
components the source code for all IntraWeb components in included, even in the evaluation edition of
IntraWeb.
XIV
55 IntraWeb Manual
14 Javascript
14.1 Overview
IntraWeb heavily uses Javascript to implement its functionality. However some users who are
comfortable with Javascript or want to add custom functionality can add their own Javascript without
having to completely bypass IntraWeb. IntraWeb contains many libraries and functions that may be
helpful.
This section will not describe every library or function as many are component specific or of little use to
the developer. Instead an overview and introduction will be presented for easy integration into the
IntraWeb javascript libraries.
1. Using the forms methods and properties: Javascript, AddToInitProc, AddValidation, ScriptFiles
3. From a custom control.
4. In a template.
5. Using ScriptEvents
Once loaded, there is a list of events associated to that control. These events correspond to JavaScript
events, therefore, any code entered has to be JavaScript code and not Delphi or C++ code.
To see how to associate an event with one of these, see the next two sections.
(Note: Since IW 3.2 controls rely EXCLUSIVELY on HTML and do no use JavaScript or CSS,
ScriptEvents is not available for these controls)
The first step is to drop a TIWEdit on the form and double-click on the ScriptEvents property. Once the
editor is displayed, click on the OnFocus event and then enter the following text in the edit box:
and enter the IWEdit1 box, the alert will show up in the browser.
The next step is to interact with the value entered in the edit box. In this case, we are going to perform
a check of the value entered to see if it is at least six characters. The first thing we need to do is define
the function that checks to see if the text length is correct:
function CheckLength(ASender)
{
if (ASender.value.length < 6)
{
alert("At least 6 characters required");
}
}
Once this function is defined, we need to be able to use it. To do so, we can add it to the JavaScript
property of the form:
The last step is to call the function from the OnBlur event of the IWEdit control. To do this, choose
OnBlur from the ScriptEvents of the control and enter the following code:
CheckLength(ASender)
"ASender" represents the actual control. In a normal HTML page with controls, "ASender" would be
"this". However, IW "proxies" the JavaScript functions and the parameter representing the object is
"ASender".
Everything that has been done previously, could also be done at runtime using the controls
"HookEvents" method. For more information regarding HookEvents, see the source directory.
Let us see an example of how to dynamically change the color of a button when the mouse pointer
moves over it. Obviously the events associated to this are OnMouseOver, OnMouseOut. In the
OnMouseOver, we place the following code:
ASender.style.color='white';
ASender.style.backgroundColor='red';
As you can see, this time the code has been entered directly into the event as opposed to calling a
function (not necessary in this case either). You can also contemplate that more than one instruction
can be entered. In the OnMouseOut we place the following code:
ASender.style.color='white';
ASender.style.backgroundColor='green';
Now when you move the mouse over the button, the background will go red and the text white. When
the mouse pointer leaves the button, the background color will change to green.
Up to now, we have seen how to associate events with a particular control and how to interact with
values/properties of the control. The next step is to see how to interact with other objects on the page.
COMPONENT_NAME{IWCL}
For example, if we have a button dropped on the form named IWButton1, the corresponding HTML
element would be:
IWBUTTON1IWCL
This way, it is easy to refer to other controls. For example, we can enter the following value in the
OnChange event of an IWEdit:
IWBUTTON1IWCL.style.color='brown';
This way, when the value in an IWEdit changes, the button color will automatically change to brown.
FindElem
FindElem takes as parameter an object name and returns the object if it is found. You can use this
function to find the instance of a certain element on the form.
SubmitClickConfirm
AConfirmation)
The first is the object name, the second is a parameter passed to the action of the form. The third is
whether validation is required or not and the fourth indicates the confirmation string. This function is
used everytime a confirmation string is entered into any control that supports the property. What
happens is the following:
When entering a value in the confirmation property of a TIWButton for example, the following code is
called:
What then happens is that SubmitClickConfirm will call a validation box with the text passed as
parameter. If the confirmation box returns True, the form will be submitted. Otherwise it will not be
submitted.
When adding code prior to a SubmitClickConfirm, make sure that the code you add returns a True or
False so that the form is submitted accordingly.
DoSubmit
XV
Page Mode 62
15 Page Mode
If developing an application (or weblication) where state management is required and each
step is interlinked with the previous, such as a contact relational management system,
application mode would be most appropriate. This is because the whole application fits nicely
into an automata scenario. For example, in normal CRM systems, a user logs in and is
presented with a menu from where he/she can access different utilities such as contact
management, customer invoices, etc. These are all tied to the same user, where Mr. Smith has
certain contacts and Miss Jones has others. Session management plays an important role here
and tracking the entire "session" is very important.
On the other hand, if there is a website where there are various independent sections, such as
News, Stock quotes and Guest Book, none of these are really linked together. One person
might want to see the news whereas another person would like to leave his/her signature.
There is no "session tracking" as such, no need to remember if the user that requested news
also requested stock quotes. This is where Page Mode fits in perfectly.
The primary difference when working with Page Mode as opposed to Application Mode, is
that the former does not offer any kind of state or session management. All this needs to be
taken care of by the developer using existing technology such as WebBroker (or WebSnap).
Again, in most cases, session management is not required in these cases. It is very important
to think through what exactly is the purpose of the web application before deciding on using
Page Mode or Application Mode, i.e., is a full-blown application being developed or a
dynamic site.
When developing dynamic sites with Page Mode, the technology behind it (as mentioned
previously) has to be either WebBroker or WebSnap. IW allows adding to this backbone by
providing "pages" to design interfaces. Think of Page Mode as pages where each page can be
designed using RAD technology with drag-n-drop of visual IW controls. Therefore, the first
step is to decide whether WebBroker or WebSnap is going to be used.
you know and understand either of these technologies to successfully develop applications
using PageMode. On the AtoZed website there is a tutorial about WebBroker for beginners.
WebBroker is a low-level interface. The problem is that it is often pitched as a high-level one.
PageMode can be considered as "plugins" that sit on top of WebBroker (or WebSnap), which
means that you are not actually building an IW application but more a WebBroker application
where parts of it are generated using IW. Consider IW in PageMode as a "third-party" add-on
to WebBroker.
The first step is to create a new WebBroker application. In this case, an ISAPI DLL will be
created. For more information on WebBroker, see the Delphi online help or tutorials on the
AtoZed website.
Once the WebBroker application has been created, a new IW form will be added to the
project. To do this, use the IntraWeb wizard page in the Object Repository. Depending on
whether the application is going to be designed for PDA devices, PageForm 3.2 should be
chosen as opposed to PageForm.
After click on the Ok button a new IW form will be displayed. This form is very similar to the
IW forms used in Application Mode, however it has some specific properties that are related
to Page Mode. In particular there are three properties that are important:
- AutoProcess
- FormAction
- PostToSelf
What AutoProcess indicates is whether the parameters will be automatically read and matched
to components on the form. This in most cases has to be set to True. Since this form
represents a actual "HTML form", an important property of any HTML form is the Form
Action. This property can be set using the FormAction. However, in most cases, the
FormAction would be to call the underlying IWPageForm itself, therefore by setting the
PostToSelf property to True, this will be taken care of and FormAction can be left blank. If on
the other hand, the post has to be handled by a WebAction defined in the WebModule,
PostToSelf would need to be set to False and FormAction would need to contain the
appropriate action.
In the case of this example (see PageForms in the Demo directory), PostToSelf is set to True
and FormAction is left blank. The next step is to drop some controls on the form.
In this case, a IWLabel and IWURL are placed on the form. The next step is to create a second
IW form. Again, using File -> New -> IntraWeb -> New Form a new Page Form is created.
Before placing any code in either form, some previous steps are required.
When using PageMode, the underlying technology takes care of displaying the forms. In
Application Mode a form would be displayed using something like:
TIWForm.Create(WebApplication).Show;
Set the Default value to True and define the PathInfo and Name (as displayed in the figure
above). As with any normal WebBroker application, there are two ways to send a response
back. One is using the property Producer and the other is by setting it in code. In this case, the
same thing can be done to display the IW form. However, there are two previous steps
required. The first is one-off per application and that is to use a IWModuleController. This is
a component that automatically creates an IWServerController. All that needs to be done is to
drop ONE of these components on the WebModule:
There are no additional properties or events that need to be assigned. Just placing one on the
WebModule is sufficient.
The next step required to display an IW form is to use a IWPageProducer component. ONE is
required PER form (or assign it dynamically at runtime). This component has only one event
which is the OnGetForm. This event returns the contents of the IW form to the broker:
This is similar to what is used in Application Mode, except that here, instead of doing a Show,
the result of creating the form is assigned to the VForm parameter. The next step is to assign
the producer to the WebAction using the Object Inspector. Since there is a second form in this
application, the same steps are performed for the second form. As can be seen from the event,
the owner of the form is also passed in as a parameter (AWebApplication). A second
WebAction needs to be defined to display the second form. This is again done in a similar
manner to the first WebAction.
Note: When adding a IWPageProducer and assigning the event in the WebModule, two units
have to be added to the uses clause, IWApplication and IWPageForm (IWPageForm32).
What is left is to display the second form from the first one using an IWURL. To do this, all
that is needed is to call the WebAction that produces the second form. The URL can be
assigned to the IWURL in the form's OnCreate event:
The second form prompts for a name and displays a label. This is programmed exactly the
same as in application mode.
Therefore you can see that working with PageMode gives you the RAD flexibility of IW and
allows you to work with existing technologies. Much of the way things are done coincides
with Application Mode, apart from some minor differences that have been mentioned in this
example.
management. IntraWeb will be used to provide the user interface. In this manner of integration
the products are quite complimentary.
The demo is a simple demo that takes a survey of two questions that are of vital importance to
the programming community. The two questions are:
It will then collect your vote and tabulate it with other voters. To see this, simply run the demo
in the browser multiple times. After it tabulates the votes it will generate a small chart
displaying the results. Full source code for the demo is included in the demos directory. We
have designed it to be simple as possible so as to make it easy to follow. It demonstrates the
following:
The first thing that must be done to use IntraWeb with WebSnap is to add a
TIWModuleController. To simplify distribution and not require distribution of external files,
IntraWeb serves "internal" files from its libraries. IntraWeb has several internal files and as a
user you can add more using IntraWeb's API.
Next we created a new WebSnap page module. To do this we selected File : New : Other :
WebSnap tab : WebSnap Page Module. The dialog is shown here:
After OK is clicked, Delphi will display the New WebSnap Page Module dialog as shown
here:
Make the settings match the settings as shown in the figure above and select OK. Delphi will
now create a new WebSnap Page Module. It should look like this:
Delete the TPageProducer and create a TIWPageProducer (from the IntraWeb Control tab).
The page module should now look like this:
Save the page module and name it Page1Module.pas. Now we need to create an IntraWeb
page form. Select File : New : Other : IntraWeb : Page Form. Save the form as
Page1Form.pas. Now lets go back and link Page1Module to Page1Form. To do this create an
OnGetForm event for the TIWPageProducer. The event needs to look like this:
procedure TPage1.IWPageProducer1GetForm(ASender: TIWPageProducer;
AWebApplication: TIWApplication; var VForm: TIWPageForm);
begin
VForm := TformPage1.Create(AWebApplication);
end;
This creates an instance of TformPage1 on demand. So that the unit will compile
IWApplication and IWPageForm must also be added to the uses clause.
Now let's go back to Page1Form and create our survey questions. We've created two
TIWLabel components, two TIWComboboxes, one TIWButton, and one TIWText. For the
comboboxes we have also set the RequireInput = False. Our Page1Form now looks like this:
Next we will add the code for the form's OnCreate event. Double click on the form and enter
this code. The code merely loads the text and identifying numbers into the combo boxes.
procedure TformPage1.IWPageFormCreate(Sender: TObject);
var
i: TSTMovie;
begin
for i := Low(i) to High(i) do begin
cmboBest.Items.AddObject(GMovies[i], TObject(i));
end;
(cmboBest.Items);
end;
Now we will add an OnClick event for the button. Double click on the button and add this
code:
procedure TformPage1.butnVoteClick(Sender: Tobject);
var
LBest: TSTMovie;
LWorst: TSTMovie;
begin
LBest := miMotionPicture;
LWorst := miMotionPicture;
if cmboBest.ItemIndex = -1 then begin
textMsg.Lines.Text :=
'Please select a choice for best Star Trek movie.';
end else if cmboWorst.ItemIndex = -1 then begin
textMsg.Lines.Text :=
'Please select a choice for worst Star Trek movie.';
end else begin
LBest := TSTMovie([cmboBest.ItemIndex]);
LWorst := TSTMovie([cmboWorst.ItemIndex]);
if LBest = LWorst then begin
textMsg.Lines.Text := 'Sorry - but you cannot pick the same
movie for best and worst.';
end else begin
if WebContext.Session.Values['Confirm'] <> 'Y' then begin
if LBest = miFinalFrontier then begin
textMsg.Lines.Text := 'Ugh. The Final Frontier was trully
horrid. Are you sure that is'
+ ' your choice for best?';
butnVote.Caption := 'Vote with my questionable choice
anwyays';
WebContext.Session.Values['Confirm'] := 'Y';
end else if LBest = miVoyageHome then begin
textMsg.Lines.Text := 'Good choice! The Voyage home was good
wasn''t it?';
butnVote.Caption := 'Record my vote!';
WebContext.Session.Values['Confirm'] := 'Y';
end;
end;
end;
end;
textMsg.Visible := textMsg.Lines.Count > 0;
if not textMsg.Visible then begin
RecordVote(LBest, Lworst);
ProduceResponse := False;
DispatchPageName('PageResults', WebContext.Response, []);
end;
end;
Now we could spend a lot of time explaining the above code. But did you notice something?
Its all standard Delphi code! So we'll just explain a few lines of interest.
The code checks to see if the user has selected information, and also makes sure that they do
not select the same movie for both choices. It also enters in its personal opinion about certain
choices and displays messages to the user by making the TIWText component visible. If the
TIWText component is not made visible, not messages are displayed and all is well. In this
case the code calls RecordVote which is a procedure in Global.pas which is part of the demo.
It then sets ProduceResponse to False. This tells IntraWeb not to render this page because we
will render it manually, or give WebSnap instructions to do so. Finally we give WebSnap
instructions to render a different page module to display the results.
There are a few properties on the form itself that we must set as well.
1.Set PostToSelf to true. This instructs the form to generate links that will send the data back
to this same form. FormAction can be set if you wish the data to be submitted to another
form. FormAction and PostToSelf (When true) are mutually exclusive.
2.Set AutoProcess to true. This instructs the form to automatically parse the HTTP variables
and set the component states accordingly. If you wish to control this process manually, you
would leave AutoProcess to false.
Next we will create another Page Module and Page Form. The steps are pretty much like the
previous one so we will not waste space on this. Instead we will start with a bank page form,
PageResultsForm.pas. We have added one TIWImage and loaded a bitmap into it. It looks like
this:
For this form we have created only one event. We have put some drawing code in the
OnRender event. The OnRender event occurs each time IntraWeb renders a form, prior to it
actually being rendered. Here is the code for the OnRender:
This screen is produced by WebSnaps login adapter. Enter test for the user name and test for
the password and click Login. This screen will now appear:
Now select your choices and click vote. Now it will display the result screen:
XVI
Deployment 78
16 Deployment
16.1 Installation
16.1.1 Overview
IntraWeb applications are completely self contained. This means that you only need to copy the
compiled output (.exe, .so, .dll, etc) to the server. You do not need to copy external files unless you
have created external files.
Demos such as the Guess demo do not rely on any external files and thus simply copying the binary
compiled ouptut to the server is sufficient.
Files
If you have files in the files directory or its subdirectories, you may need to copy those to the server as
well. If so, they must resided in a files subdirectory that is placed in the same directory as the binary
executable.
Templates
If you made use of tempaltes, you will need to copy those to the server as well. They must resided in a
templates subdirectory that is placed in the same directory as the binary executable.
16.1.3 Permissions
By default an IntraWeb application needs very few permissions to execute. These are the minimum
requirements:
In addition if you are connecting to a database you will need to make sure that the application has
proper permissions. This is especially true for local databases which access database files directly.
If using the BDE, you need to take special care so that the BDE can create its work directories as well
as access the data files.
16.1.4 ISAPI
16.1.4.1 Deploying in IIS
Although an IW ISAPI application is the same as a standard ISAPI application, the steps to
deploy an IW ISAPI will be explained step by step. However, due to the number of existing
servers that support ISAPI's, this section is restricted to deployment on Microsoft's Internet
Information Server. This is one of the most common servers to deploy ISAPI's on.
Before deploying the application, the first step is to configure IIS to allow ISAPI's to run. In
IIS 5.0 which is the version included in Windows 2000 and Windows XP, the first step is to
create the website and under this one create a virtual folder that has execute permissions to
run ISAPI applications.
Once the website is created (or on an existing website), right click with the mouse button and
choose New -> Virtual Directory
Click Next on the Wizard Introduction screen. The next step is to select an alias for this
virtual directory. Normally, the standard is to use "scripts", however whatever alias desired
can be used. This defines how the application will be called via the URL:
http://xxx.xxxx.xxx.xxx/{alias}/xxxxxxxxxx
The next step is to choose the actual physical directory where the files are going to reside and
where the alias defined in the previous step will point to. Again, by default this would be
something like c:\inetpub\scripts. This of course depends on where IIS was installed and
where the directory for the current website resides.
The last step is to choose what permissions the virtual directory is going to have. Normally, it
is not a good idea to mix directories that have executables with directories that have files to be
accessed for reading/writing. Actually, it is not recommendable to have any directories with
write-access via IIS. In this case, the best option is to remove all permissions except the
Execute (such as ISAPI applications or CGI).
These are the steps required to configure IIS to run ISAPI's. However, before being able to run
the application, there are a few more issues required. If the system is using NTFS, it is
necessary to make sure that the physical directory that was entered in step 2 of the wizard and
where the virtual alias points to, has execute permissions. Permissions for IIS are based on
two factors, the ones assigned in IIS itself and those of the underlying file system, prevailing
the latter over the former. Of course, if running FAT (highly un-recommended) there are no
file level permissions.
The last step remaining is to copy the ISAPI into the appropriate physical directory that was
setup, make sure that the ISAPI has execute permissions and copy any necessary files (such as
Files and Templates folders) under the physical directory.
Once all these steps have been accomplished the application can be called using the URL:
http://xxx.xxx.xxx.xxx/{alias}/{application_name.dll}/{start_command }
Optionally if a different port than the default 80 has been configured in IIS, this value will
need to be appended to the URL.
There is an important issue to remember when deploying ISAPI's under IIS (or for that matter
under any other ISAPI compliant server), and that is that the ISAPI runs under certain security
restrictions. In particular it runs under the context of a specific user, which in the case of IIS is
IUSR_MACHINENAME, where MACHINENAME is substituted with the name of the
server. This user has very restrictive security permissions and this has to be taken into
consideration when certain calls require a higher level of security (such as communicating
with COM objects, connecting to certain databases that require file access, etc).
As with any other ISAPI application, IW ISAPI's are DLL's and as such remain in memory
after the first call. IIS allows them to be unloaded by configuring an application "area". To do
this, right-click on the newly created virtual directory (in the figure below this is named
scripts) and click on properties.
Once the property screen appears, click on the Virtual Directory tab to gain access to the
Application Settings.
Enter a value for the Application Name (such as Scripts or IW Applications) and click on the
Create button. Set the Application Level to the required isolation. Normally Medium (Pooled)
is sufficient. For more information on isolation levels, consult the online help for IIS. When
the application is accessed, the Unload button will be enabled and by accessing the properties
and clicking on the Unload button, ALL ISAPI's located under the virtual directory will be
removed from memory. Therefore, this only needs to be done ONCE per virtual directory.
These ISAPI management utilities can assist you with management of your ISAPI DLLs.
· DataWeb - http://www.turbodb.de/en/support/isapi.html
· EggCentric - http://www.eggcentric.com/
16.1.4.3 ISAPI Hosting
A list of hosting services which support ISAPI can be found on our website at:
http://www.atozedsoftware.com/intraweb/hosts.html
16.2 Methods
16.2.1 Notes
IntraWeb applications can be deployed as a Windows service / Linux daemon, a standalone
executable, an ISAPI application, or an Apache DSO. Using page mode IntraWeb applications can be
deployed by other methods as well.
Application mode executables may only be deployed as ISAPI, NSAPI or Apache DSO.
Application_name –install
This will install it and the application will appear in the Services Applet. From there, it can be configured
to run automatically or manually. There is no need to activate the "Interact with Desktop" under the
properties of the service, and doing so will have no effect whatsoever.
In a similar way, if the need arises to uninstall the application, it can be done by typing:
Application_name –uninstall
Notes
1. Only Windows NT, Windows 2000, and Windows XP support services. Windows 95, Windows 98
and Windows ME do not support services.
2. Services do not function in evaluation mode. Attempts to do so will result in errors.
Syntax: http://<server>:<port>
Example: http://www.atozedsoftware.com:4000
ISAPI Usage
Syntax: http://<server>/<script path>/<dll>
Example: http://www.atozedsoftware.com/iw/guess.dll
16.3.2 Sessions
Every time this URL is entered into the browser and new session is created and the user is tracked
automatically throughout the whole period that the session lasts. Optionally, parameters can also be
specified when calling a new instance by passing them using POST or GET.
http://www.atozedsoftware.com:4000?param1=value1¶m2=value2
These parameters are available in your application by accessing the RunParams property of the
TIWApplication object.
In addition, prelaunch changes can be performed in the ServerController.OnNewSession event. One
such use may be to read the parameters that have been passed in an offer different users different
starting forms.
IMPORTANT NOTE:
Some browser on Macintosh require the start parameter to have an additional / before the ?. For
example, the following:
http://<server>:8888?param1=value1
might not work correctly on some Macintosh browser and should be changed to:
http://<server>:8888/?param1=value1
Since nearly all browser accept /?, there should not be side-effects of adding / before the ? in all calls.
Installing a full blown X Server on a Linux server machine is not desirable or even possible in many
cases. Instead you can run a special X server designed for web servers called X Virtual Frambe Buffer,
or Xvfb for short. Xvfb is used by thousands of CGI and Apache DSOs.
Xvfb is included in many distributions such as SUSE. If you do not have Xvfb you can obtain it from
one of the following URLs:
· http://www.xfree86.org/4.0.1/Xvfb.1.html
· http://chartworks.com/support/server/XvfbonUnix.html
· http://www.slac.stanford.edu/grp/cd/soft/unix/xvfb.html
No configuration is required.
export DISPLAY=localhost:99.0
XVII
87 IntraWeb Manual
17 Performance Evaluations
17.1 Tips
You will likely want to test the performance of your application. Many users test the performance
improperly and thus receive misleading results. When testing be aware of the following items that can
negatively impact your tests.
1. When using Internet Explorer, the first page will render quickly. However, when you click on a
button or a link from the first page, Internet Explorer will then load extra libraries and cause a
delay. This delay is caused by Internet Explorer and not the IntraWeb application. As you
move to successive pages, you will notice that this delay no longer exists.
2. When using a browser on the same machine as the server the network is forced to use the
"loopback" address. The loop-back address generally provides good performance however
sometimes will introduce delays into the transfer of data.
3. When using a browser on the same machine as the server, the browser, network and
application all compete for CPU, disk and memory at the same time. Most browsers are quite
CPU and memory intensive, and thus negatively impact the server and your results.
4. When using Netscape and running your application from Delphi, the Delphi debugger hooks
and Netscape conflict. Often you will have to task switch from the browser to the application to
"unstick" the local network.
5. Anytime you run your server from within Delphi, Delphi's debugger is active. The debugger not
only consumes memory and CPU, but can also slow down the execution of your application.
Under normal circumstances, this is perfectly acceptable, however keep this in mind if you are
testing performance.
6. The first time you execute an ISAPI based application the web server must load the DLL and
this will cause for a delay.
To properly test performance, you should run your application and browser on separate machines.
XVIII
89 IntraWeb Manual
This will distribute the load across the servers. This method does not perform true load balancing, as it
does not measure the load, it just distributes it. In most applications, the law of averages applies and it
is quite effective. If your application is such that it creates large imbalances, you will need to use a load
balancing DNS server instead.
The virtual entry or web page merely redirects the web browser to a URL containing its individual IP
instead of iwapp.atozedsoftware.com. For example if our URL is http://iwapp.atozedsoftware.com, this
entry might redirect the browser to . This URL demonstrates a stand alone IntraWeb application, but it
can be adjusted to redirect to a static page, an ISAPI version, or a DSO version. The important thing is
that the browser is redirected to the physical application server so each subsequent request will return
to that server.
XIX
Secure HTTP / SSL 92
19.1 Introduction
If your application is deployed as an ISAPI DLL or an Apache DSO, you need to use the hosting web
server's SSL capabilities since it handles the HTTP protocol.
In Stand Alone mode, SSL is supported also. The first step is that you must obtain SSL certificates.
If your certificates are not in .pem format, please see the section on converting to PEM format.
This procedure assumes that you have already received your key and certificate pair from some
Certificate Authority (like Verisign or Thawte) and that you have them installed in Microsoft Internet
Explorer in Personal Certificates Store.
Export Certificate
Select the certificate and export it as a .pfx file (Personal Exchange Format). You may optionally
protect it with a password.
Key.pem
Create key.pem with notepad and paste everything between and including these two statements:
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
Cert.pem
Create cert.pem with notepad and paste everything between and including these two statements:
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
Root.pem
The final file that IntraWeb requires is the Certificate Authority certificate file. You can obtain this from
the Internet Explorer in Trusted Root Certificate Authority dialog. Select the Authority that issued your
certificate and export it in Base64 (cer) format. This format is also the same as PEM format so after
export simply rename the file to root.pem.
19.4 Example
An example with a test certificate is included and can be seen by examining the StandAloneSSL demo.