Delphi/WebServers - IntraWeb
IntraWeb is Delphi's new way to create web pages,
replacing the older
Web Server Application
that used TPageProducer and related components.
This new method has many advantages and several distinct problems.
Overview
| Tutorial
| Flash Objects
| OnAuthRequest
| TIWDynamicChart
| Other
| The Bottom Line
Overview
IntraWeb allows you to create a pseudo form
- you define the web page by placing special
components on the form.
When the program runs, it replaces those components
with html that performs similar functions.
To simplify test, the compiled program can be a web server
(so you won't need IIS or Apache).
When you click the Execute icon (the globe), the server
tells your browser to open a page similar to the following.
http://127.0.0.1:3719/EXEC/0/1mw0wd40hgi7np1enh3el0ywmzju
http://127.0.0.1:8888/EXEC/0/0lxsbrn1cccmoh1deem8a1f4akg7
|
When the browser requests the page, the server returns
html based on the form design -
you can view this code by using the browser's
View Source method (in IE, just right click).
Unfortunately, the html is very poorly formatted -
you will HAVE to manually reformat it to make sense of it.
(There is no reason for this - the pages I create using Delphi 5
are very easy to read.)
Tutorial
There isn't a tutorial - you are totally one your own with this.
There is no usable help in Delphi 2006 ...
unless you type in IntraWeb, then there is a whole lot of
almost help. (Good luck)
The
Intraweb spellbook
is a simple, but very nice, tutorial (Delphi 7).
Actually, the basics are very simple
- Create a new project
- File / New / Other... / Delphi Projects / IntraWeb Application Wizard
- File / New / Other... / Delphi for .NET Projects / IntraWeb Application Wizard for Delphi for .NET
- Accept the dialog defaults and create the project
- Add TIWxxx components on the "form"
- Run the program (F9) - this starts a standalone web server
- In the server, click the Execute icon (the globe)
- The page is displayed in the default browser
- Use the browser's View Source method to see the html code
- Close the browser and the server before making changes
(Use File / Shutdown, or click on the X, to stop the server)
Well, its not that simple the first time
- The first time I pressed run, the standalone server started
and the Windows Firewall complained
Do you want to keep blocking this program?
|
- I selected Unblock
- Then I was able to click the globe (F9) to start the server
(Starting the server was not in the tutorial)
In another test, I told the firewall to leave it blocked -
it still worked. Apparently, since it is a local server,
it does not matter which selection you use.
Based on what I found on the internet,
for 2 days I thought IntraWeb was for .NET ONLY.
When I was looking through the directory structure (for examples),
I found that IntraWeb supports
both win32 and .NET - that was a big supprise.
Apparently, support for win32 exists all the way back to Delphi 5 ...
but it was not a part of the Delphi distribution until version 7.
The html contains links to 4 javascript files -
I was never able to find the source for these.
Flash Objects
Flash objects are embedded via TIWFlash ...
don't waste your time with this one.
- Wrong html code
- When developing applications with Adobe Flash CS3, there is a dialog box
that publishes the Flash object to a web page - basically, it creates
the html and provides a javascript file that makes the code cross platform.
The IntraWeb method produces only one (of 3) parts of the Adobe suggested html
and does not supply the Javascript file.
In all fairness, Flash CS3 came out after Delphi 2006. However, this was easy to
fix in Delphi 5 (because it is template based) -
I have no idea with IntraWeb.
- F1 Help
- F1 (and Ctrl-F1) help produce - Topic not available -
but ... if you type in TIWFlash a lot of (mostly worthless)
help is found. Apparently, the help index is screwed up ... again.
(Screwed up help is the main reason that, after buying
Delphi 2006 upgrades,
we still develop using Delphi 5 whenever possible.)
- Flash file not found
- Based on the generated html, the flash file MUST be located
in the Files directory - /Files/abc.fla -
well I never got that to work.
- Flash Player Version
- The html code allows you to specify the minimum Flash player version
necessary to play your movie. Unfortunately, this information is
hardcoded for Flash version 5 ... and all my applications require 9.0.45 or newer.
This shows the old and new html commands.
codebase="http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0"
|
This is fixed by the following code
procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
IWFlash1.CodeBase:='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0';
end;
|
This is NOT in the help file.
- FlashVars
- There is no way to set the following param tag - this is how
parameters are passed to Flash objects
<param name="FlashVars" value="Filename=Temp_RH_Data_short.txt&ini=Example_Time_Auto.ini.txt&callbacks=t" />
|
Just to make the point, this static page displays one of my
Flash-based graphs
that will not, and can never, work with IntraWeb.
OnAuthRequest
According to the
Intraweb spellbook tutorial,
there is supposed to
be an IWServerController.OnAuthRequest event that triggers the browser
logon dialog (authentication request) - I was never able to find it.
I have an application that needs this type of functionality -
I guess I will need to look else where.
TIWDynamicChart
The first time I tried to use TIWDynamicChart,
there was some kind of message about it not being compatible.
I spent several hours trying to figure out what that might mean
- no luck.
At this point, I can no longer get the message, but BDS 2006 crashes
every time I try to add a TIWDynamicChart.
This component was the only reason I tried to use IntraWeb -
I have some data that I want to plot and display in a web page.
You know, if it is in the tool palette, then it should work.
I was able to get this when using win32 Delphi 2006 Architect
Dynamic Charts are not available in this edition of IntraWeb
|
Other
I did not find a way to control
- Cookies
- HTTP commands - like Show logon dialog (status = 401)
I am sure that methods to control these are available,
but I have already spent (wasted) enough time with this ...
and these are not in the IntraWeb help.
Apparently, these are handled via the .NET framework -
examples in basic and c# ... not Delphi.
It may be possible to control these via the ServerController object
which provides access to TWebRequest and TWebResponse
... but I have not tested that.
procedure TIWServerController.IWServerControllerBaseBeforeDispatch(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
begin
end;
|
Additional notes using Delphi 2006
- IWLayoutMgrForm1 does not do anything
- IWPageProducer1 does not have any useful properties
- IWLayoutMgrHTML1 is in win32 only, not .NET
- The component icons (the actual images) are different in win32
and .NET (actually, in .NET all Intraweb components have the same icon)
The Bottom Line
For some applications, IntraWeb might actually work,
but for what I do, this was a complete waste of time.
Author: Robert Clemenzi -
clemenzi@cpcug.org