CGI Framework
CGI Framework basics

Basics

Docs

Components

Templates

Tools

Demos


SourceForge.net Logo

Brasil
   

CGI Framework basics

The most important piece of CGI framework is TPageBuilder component, so, let's start on it.

TPageBuilder basics

TPageBuilder is a replacement for TPageProducer, the original Borland CLX component for dynamic html page generation. As a replacement part, TPageBuilder features a set of properties, methods and events that looks very similar to the TPageProducer counterparts.

By other side, TPageBuilder is not a perfect replacement for TPageProducer. You simple can't take a PageProducer and put a PageBuilder on place. For me, makes no sense to implement a new object exactly equal to a existing one.

TPageBuilder have HTMLDoc property and like in TPageProducer, it is a TStrings, and you put your html template directly in that property in design time, just like in TPageProducer.

Once again, we have a HTMLFile to point to a template stored on disk.

No, we don't have support to server side scripting using JScript, VBScript, Perl or PHP. Release 1.0 also, will not have such support, but future is all wide open.

TPageBuilder also implements Content, ContentFromString and ContentFromStream methods in a similar way TPageProducer do.

You can also provide a handler for OnHTMLTag event. This one have a slightly different parameter list from its TPageProducer counterpart.

TPageBuilder unique features

The main difference between TPageBuilder and TPageProducer are invisible tags. TPageBuilder does not use invisible tags. In exchange, TPageBuilder uses tags with name spaces, similar to XML tags.

To make everything simpler, let's take a example:

<html>
  <head>
    <title><pb:var name="title"/></title>
    <meta name="generator" value="CGI Framework">
  </head>
  <body>
    ... Your html content...
  </body>
</html>

In the above example, "<pb:var name="title"/>" is a typical PageBuilder tag. "pb" is the namespace and "var" is the tag id. That tag has 1 parameter (name) whose value is "title". A slash (/) just before the closing angle bracket indicates it's a simple tag, with no content.

In a completely different way from TPageProducer's invisible tags, a TPageBuilder tag can have a "end tag" with an arbitrary html content between the start tag and the end tag, as in the following example:

<html>
  <head>
    <title><pb:var name="title"/></title>
    <meta name="generator" value="CGI Framework">
  </head>
  <body>
    <table>
      <tr>
        <td>Code</td>
        <td>Description</td>
        <td>Price</td>
        <td>Available</td>
      </tr>
      <db:browse dataset="products">
      <tr>
        <td><db:field dataset="products" name="Code"/></td>
        <td><db:field dataset="products" name="Description"/></td>
        <td><db:field dataset="products" name="Price"/></td>
        <td><db:field dataset="products" name="Available"/></td>
      </tr>
      </db:browse>
    </table>
  </body>
</html>

In that new example, "<db:browse dataset="products">" and "</db:browse>" encloses some html code. That html code is the "db:browse" tag content. Note the presence of some "db:field" tags inside "db:browse" content.

On execution time, OnHTMLTag event handler will be called for "db:browse" tag processing. That handler may recursively call the html parser to have "db:field" tags processed by its turn.

Note that, you can arbitrarily choose your namespaces and tag ids. However the tags "pb:title", "db:browse" and "db:field" have that name for a very good reason as we will see ahead.

 


Copyleft (2002) Ivan C. Cruz
Site contents may be reproduced in all or in part since you provide a clear statement citing that site as your source.

That site was built and tested with Mozilla. If some components looks misalligned or not properly rendered, it may be your browser fault. In that case, please, consider an upgrade.