Menu
   Read: IDE Highlights  
   ▶ Web Actions  

Web Actions: Writing custom web action components

The WebHub class library includes a class called TwhWebActionEx. It is special for two reasons:
  1. Whatever the component does, that action can be triggered from the web simply by calling its name. If the component is called WebMailForm then WebMailForm.execute from a WebHub page will cause the component to execute/run. In the case of WebMailForm, which is included with WebHub, it will send an email message.
  2. Save-state features are included. So even though there might be a thousand people sharing your custom application in an afternoon, each one of them gets to use the component with their own properties set just the way they require. Examples would be: number of search results returned, graphics preferences, or foreign language translation.

Besides giving you the "base class" for TwhWebActionEx, WebHub also gives you a number of derived components for special purposes. By using these components you save yourself anywhere from hours to weeks of work in implementing special purpose features. Here are some popular examples:

  • TwhdbScan - displays a database-driven HTML table, with scrolling and many other features.
  • TwhMailForm - sends email messages including form letters with surfer data "merged" in.
  • TwhPicture - processes BMP to GIF conversions (a separate license is required from Unisys).
  • TwhDropDown - create HTML drop-down boxes that save-state
  • and many more!


Once you learn to program Web Action components, you have unlocked the power of WebHub. Here is a simple HELLO, WORLD example so you can see the syntax. This code goes on the OnExecute event of the TwhWebActionEx component which has been named waHello in this example.
procedure TfmAppSendStr.waHelloExecute(Sender: TObject);
begin
  inherited;
  with TwhWebAction(Sender).Response do 
  begin
    SendHdr('2','Hello, World!');
    Send('The time is '+DateTimeToStr(now));
  end;
end;
Running: WebHub-v3.287 compiled with d29_win64 on Microsoft-IIS/10.0,
Fri, 29 Mar 2024 05:13:41 UTC
Session 1854242755, 0 pages sent to claudebot at 54.87.90.21;
Time to produce this page: 0msec.