Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder...

78
Elevate Web Builder Modules Manual Table Of Contents Chapter 1 - Getting Started 1 1.1 Creating a Module 1 1.2 Handling Requests 3 1.3 Custom DataSet Modules 8 Chapter 2 - Component Reference 9 2.1 TEWBDatabaseAdapter Component 9 2.2 TEWBDataSetAdapter Component 13 2.3 TEWBMIMEPart Component 25 2.4 TEWBMIMEParts Component 32 2.5 TEWBModule Component 35 2.6 TEWBServerRequest Component 37 Chapter 3 - Type Reference 73 3.1 TEWBGetDataSetAdapterEvent Type 73 3.2 TEWBInitializeDataSetAdapterEvent Type 74 3.3 TEWBModuleExecuteEvent Type 75 3.4 TEWBRequestMethod Type 76 Table of Contents Preface

Transcript of Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder...

Page 1: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Elevate Web Builder Modules Manual

Table Of Contents

Chapter 1 - Getting Started 1

1.1 Creating a Module 1

1.2 Handling Requests 3

1.3 Custom DataSet Modules 8

Chapter 2 - Component Reference 9

2.1 TEWBDatabaseAdapter Component 9

2.2 TEWBDataSetAdapter Component 13

2.3 TEWBMIMEPart Component 25

2.4 TEWBMIMEParts Component 32

2.5 TEWBModule Component 35

2.6 TEWBServerRequest Component 37

Chapter 3 - Type Reference 73

3.1 TEWBGetDataSetAdapterEvent Type 73

3.2 TEWBInitializeDataSetAdapterEvent Type 74

3.3 TEWBModuleExecuteEvent Type 75

3.4 TEWBRequestMethod Type 76

Table of Contents

Preface

Page 2: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

This page intentionally left blank

Table of Contents

Preface

Page 3: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Chapter 1Getting Started

1.1 Creating a Module

To create a new module in RAD Studio XE6 (Delphi), please complete the following steps:

1. In the RAD Studio XE6 IDE, select the File/New/Other menu option from the main menu.

2. The New Items dialog will then appear. Select the Elevate Web Builder option folder from the liston the left-hand side of the dialog. Click on the Elevate Web Builder Module and then click on the OKbutton.

Getting Started

Page 1

Page 4: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

3. The Browse for Folder dialog will then appear. Select the desired target folder for the new moduleproject and click on the OK button.

4. The new module project will be created in the desired target folder and opened as the active project inthe RAD Studio XE6 IDE.

Please see the Handling Requests topic for more information on adding the appropriate code for handlingincoming requests to the module.

Getting Started

Page 2

Page 5: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

1.2 Handling Requests

NoteBefore reading the following material, please be sure that you understand how HTTP requestswork by reading the Using Server Requests and Using the Web Server sections of theElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections containimportant information such as how server requests work and how HTTP headers are formatted.

Incoming Requests

When an HTTP request is received by the Elevate Web Builder Web Server, the URL of the request ischecked to see if the request is for static content or a dataset request. If the URL for the request is notthat of static content or a dataset request, then the URL is checked to see if it is an Elevate Web Buildermodule request. A module request is any request that uses the following URL structure:

http://<Domain Name>/<Modules Resource Name>/<Module Name> orhttps://<Domain Name>/<Modules Resource Name>/<Module Name>

NoteThe <Module Resource Name> component of the URL is the resource name for modules definedin the Elevate Web Builder Web Server, but can be changed in the web server configuration. Ifyou've changed the default modules resource name of 'modules', then please replace anysubsequent references to the default 'modules' resource name in the following examples with theresource name that you're using instead.

If the URL matches this pattern, the web server will automatically instantiate a TEWBModule componentto represent the module specified in the URL for use with the request. The web server will then pass therequest information to the module instance by firing its OnExecute event handler. The request is passedto the OnExecute event handler as an instance of the TEWBServerRequest object. ThisTEWBServerRequest object instance is used both to retrieve information about the request and to sendcontent as a response to the request.

WarningEach module instance is executed in a separate thread, so you must make sure that all codeincluded in an OnExecute event handler is completely thread-safe. Also, all modules in the webserver run in-process, so a fatal error such as a memory overwrite due to improper threading codein a module could cause the server to fail.

Determining if a Request Is Secure

You can determine if a request is secure (using HTTPS) by examining the RequestSecure property of theincoming request.

Getting Started

Page 3

Page 6: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

NoteThe web server does not currently support secure requests.

Determining the Request Type

Module requests are always either HTTP GET or POST requests and never HTTP HEAD requests. You canfind out the request type by examining the RequestMethod property of the incoming request.

Determining the Browser Type

You can determine the type of browser that is submitting the request by examining the followingproperties of the incoming request:

RequestIERequestFireFoxRequestChromeRequestOperaRequestSafari

NoteThese properties are set by the web server examining the RequestHeaders that are passed to theweb server as part of the request, and therefore can be easily forged by any client that is trying toimpersonate a particular browser. However, for the majority of clients, these properties willaccurately reflect the browser being used on the client.

Reading URL Parameters

Parameters are specified in a URL in the following manner:

<BaseURL>?<Params>

<Params> = <Param> [? <Param>]

<Param> = <Key>=<Value>

For example, the following URL will result in a request to the module called "Compute" with parametersfor X and Y axis values:

http://www.domain.com/modules/compute?x=100&y=200

The URL and any parameters included in the URL are specified in the request's RequestURL andRequestURLParams properties, respectively. The RequestURLParams property, however, is in its rawform. To examine the URL parameters in an easier manner, use the RequestParams property. TheRequestParams property is a TStrings instance of key-value pairs that represent all URL parameters. Touse the above example, the following values would be present in the RequestParams property for thespecified URL:

Getting Started

Page 4

Page 7: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

x=100

y=200

Reading Request Cookies

Cookies are simple textual data that is persisted in the client across connections to the web server. Anycookies that apply to the request URL will automatically be sent by the client and will be available in theTServerRequest RequestCookies property. The RequestCookies property is a TStrings instance of key-value pairs that represent all applicable cookies. See the Sending a Response section below forinformation on how to set cookies in responses.

Reading Request Content

POST requests are normally accompanied by content that is submitted as part of the request. TheRequestContentType, RequestContentLength, and RequestContent properties of the request contain thecontent type, content length, and actual content.

HTML Form Submittals

When an HTML form is submitted to the URL for the module, the form data may be sent over using oneof two formats. Depending upon value of the RequestContentType property, the web server willautomatically perform some pre-processing of the incoming conent in the following ways:

application/x-www-form-urlencoded

This is the default encoding for form submittals, and common for form submittals that do notinclude file uploads. The web server will pre-parse all textual form variables and they areaccessible via the RequestContentParams property as key-value pairs

multipart/form-data

If a form submittal includes one or more file uploads, then the browser will use a special MIMEencoding. The web server will pre-parse all textual form variables as with the default encoding, butwill also include any file content in the RequestMIMEParts property, with each file in its ownTEWBMIMEPart instance. Each TEWBMimePart instance includes both Headers and Content. TheHeaders property contains MIME headers, which are formatted in the same fashion as HTTPheaders. These headers can be used to determine how to deal with the Content property, and themost useful are:

Header Description

Content-Transfer-Encoding This header identifies the encoding of the file contentcontained in the Content property. This is essential inknowing how to deal with the content.

Content-Disposition This header identifies the actual name of the file. This isuseful if the file content must be saved under its sourcename and then later retrieved using its file name.

Sending a Response

The web server doesn't automatically send a response to an HTTP request once the OnExecute eventhandler terminates, so it is important that you send a response from within the OnExecute event handler.You can use one of several methods to send a response to the client's request:

Getting Started

Page 5

Page 8: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Method Description

SendContent Sends Unicode content as a UTF-8 string along with anoptional HTTP status code and message.

SendCustomContent Sends Unicode or ANSI content in a specific encoding with aspecific disposition. The disposition is used to give the clientan indication of how the content should be saved, such asthe file name for a file.

NoteThere are two SendCustomContent methods, one forUnicode strings and one for ANSI strings.

SendRedirect Sends the new location (URL) for a resource (if its locationhas been changed) along with a optional Unicode content asa UTF-8 string, HTTP status code, and message.

SendError Sends a Unicode error message along with an HTTP status(error) code.

WarningOnce one of the above methods is called, you should clean up any allocated resources and exitthe OnExecute event handler. Not only is it important that you call one of the Send methods, it isalso equally important that you do not call one of the above methods more than once, or morethan one method.

Setting Cookies

As indicated above, any cookies that are stored on the client and are applicable to the request URL canbe found in the RequestCookies property. You can add or modify such cookies by assigning key-valuepairs to the TServerRequest ResponseCookies or ResponseSessionCookies properties. The key is thename of the cookie, and the value is the value to assign to that cookie. To "delete" a cookie, simply setits value to nothing.

NoteYou must set any cookies before calling any of the TServerRequest Send* methods detailedabove, or the cookies will not be set properly on the client.

There are three cookie attributes that are also important. Cookie attributes are specified after the valueof a cookie and are always prefixed by a semicolon.

Getting Started

Page 6

Page 9: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Attribute Description

expires Specifies the date/time that the cookie expires as a GMTstring. To convert a TDateTime into a GMT string, use theTServerRequest DateTimeToGMTStr method. If you do notspecify an expiration attribute, then the web server willautomatically set the expires attribute as 1460 days from thecurrent date/time for all cookies specified in theResponseCookies property. The web server will not set theexpires attribute for any cookies specified in theResponseSessionCookies property, which means that theywill automatically not persist past the current client session.This is useful for session IDs and other types of informationthat you do not want to be present in a new or differentclient session.

domain Specifies the domain that the cookie applies to. If you do notspecify a domain attribute, then the web server willautomatically set the domain attribute to that of theconfigured domain for the web server. Please see the ElevateWeb Builder manual for more information on configuring theweb server domain.

path Specifies the path attribute that the cookie applies to. If youdo not specify a path attribute, then the web server willautomatically set the path attribute to a single forward slash,meaning that the cookie applies to all paths within thecookie's domain.

Getting Started

Page 7

Page 10: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

1.3 Custom DataSet Modules

Custom dataset modules are exactly like any other module, but are coded to handle custom datasetsusing the TEWBDatabaseAdapter and TEWBDataSetAdapter components and are designated as thecustom dataset module in the Elevate Web Builder Web Server configuration.

Please see the main Elevate Web Builder product manual for more information on configuring the ElevateWeb Builder Web Server to use a custom dataset module.

Custom DataSet Module Example

The Elevate Web Builder Modules installation includes an example custom dataset module project thatshows how to load a "biolife" dataset from a TClientDataSet instance that loads its contents from an XMLfile. This project also demonstrates the usage of the TEWBDatabaseAdapter and TEWBDataSetAdaptercomponents for generating/consuming JSON from TDataSet-descendant component instances inDelphi/C++Builder. It is installed into the \examples\datasetmodule subdirectory under the maininstallation directory of the Elevate Web Builder Modules installation.

In addition, a custom dataset client example project called datasetclient.wbp is automatically installedwith the example applications that come with Elevate Web Builder. It provides the front-end foraccessing the "biolife" dataset that is handled by the custom dataset module example project.

Getting Started

Page 8

Page 11: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Chapter 2Component Reference

2.1 TEWBDatabaseAdapter Component

Unit: ewbdatasetadapter

Inherits From TComponent

The TEWBDatabaseAdapter component is used in conjunction with various TEWBDataSetAdaptercomponents to load JSON dataset transactions into generic TDataSet descendant components. This isuseful for custom dataset modules that need to deal with data from a data source that isn't supported byElevate Web Builder's automatic dataset handling.

Properties Methods Events

Commit OnGetDataSetAdapter

GetDataSetAdapter

Component Reference

Page 9

Page 12: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDatabaseAdapter.Commit Method

procedure Commit(const Operations: String)

procedure Commit(const Operations: AnsiString)

Use this method to load JSON transaction operations received from an Elevate Web Builder clientapplication into a database.

NoteThis method will automatically call the GetDataSetAdapter method as necessary to get access tothe required dataset adapters for completing the transaction operations. If a dataset adaptercannot be accessed for a particular dataset, then an exception will be raised and the commit willfail.

Component Reference

Page 10

Page 13: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDatabaseAdapter.GetDataSetAdapter Method

function GetDataSetAdapter(const DataSetName: String):

TEWBDataSetAdapter

Use this method to trigger the OnGetDataSetAdapter event and retrieve the dataset adapter instance forthe specified dataset name.

Component Reference

Page 11

Page 14: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDatabaseAdapter.OnGetDataSetAdapter Event

property OnGetDataSetAdapter: TEWBGetDataSetAdapterEvent

This event fires when the GetDataSetAdapter method is called.

NoteIf the Adapter variable parameter is not assigned a value, then it can cause an exception to occurduring commit operations that reference the specified dataset name.

Component Reference

Page 12

Page 15: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

2.2 TEWBDataSetAdapter Component

Unit: ewbdatasetadapter

Inherits From TComponent

The TEWBDataSetAdapter component is used in conjunction with the TEWBDatabaseAdapter componentto create and load JSON dataset transactions, columns, and rows to/from a generic TDataSet descendantcomponent. This is useful for custom dataset modules that need to deal with data from a data sourcethat isn't supported by Elevate Web Builder's automatic dataset handling.

Properties Methods Events

DataSet BuildColumns OnInitialize

KeyCaseInsensitive BuildLoad

KeyFields BuildRows

LocalizeDateTimeColumns GetLoadContentType

NumKeyFields Initialize

Component Reference

Page 13

Page 16: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.DataSet Property

property DataSet: TDataSet

Specifies the TDataSet-descendant component to use for the dataset adapter.

NoteThe dataset must be capable of uniquely identifying rows using a primary key or some othermethod in order to work properly when inserting, updating, or deleting rows during transactions.

Component Reference

Page 14

Page 17: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.KeyCaseInsensitive Property

property KeyCaseInsensitive: Boolean

Specifies whether the key fields for the dataset are case-insensitive.

NoteThis property can be set directly at any time, but it will automatically be cleared if the Initializemethod is called.

Component Reference

Page 15

Page 18: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.KeyFields Property

property KeyFields: String

Specifies the key fields for the dataset, with each key field separated by a semicolon (;).

NoteThis property can be set directly at any time, but it will automatically be cleared if the Initializemethod is called.

Component Reference

Page 16

Page 19: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.LocalizeDateTimeColumns Property

property LocalizeDateTimeColumns: Boolean

Specifies whether the adapter will localize date/time column values in the dataset when converting themto/from strings. The default value is False.

NoteThis property was added in 1.02 Build 2 and was part of a breaking change to date/time valuelocalization for datasets. Prior to 1.02 Build 2, date/time values were always localized, whichresulted in some odd date/time values if the time zone of the web browser was a significantdistance from the physical web server.

Component Reference

Page 17

Page 20: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.NumKeyFields Property

property NumKeyFields: Integer

Specifies the number of key fields for the dataset.

NoteThis property can be set directly at any time, but it will automatically be cleared if the Initializemethod is called.

Component Reference

Page 18

Page 21: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.BuildColumns Method

function BuildColumns: String

Use this method to build a JSON string containing all of the column definitions for the dataset specified inthe DataSet property.

Component Reference

Page 19

Page 22: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.BuildLoad Method

function BuildLoad(const Column: String; const RowKey: String):

AnsiString

Use this method to build an ANSI string containing the value for the specified BLOB field in the datasetspecified in the DataSet property. The RowKey parameter is a semicolon-delimited (;) list of key valuesthat uniquely identify the row that contains the desired BLOB field data.

Component Reference

Page 20

Page 23: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.BuildRows Method

function BuildRows(const ResourceName: String; Params:

TStrings=nil; const User: String=''; const Password: String=''):

String

Use this method to build a JSON string containing all of the rows for the dataset specified in the DataSetproperty.

The Params parameter is used to include any additional dataset filtering parameters with any BLOB loadURLs that are included with the JSON row data built by this method. This ensures that any BLOB loadsare executed using the same filtering parameters that were used to build the rows.

The User and Password parameters are used to include user and password authentication parameterswith any BLOB load URLs that are included with the JSON row data built by this method. This ensuresthat any BLOB loads are authenticated using the same credentials that were used to build the rows.

Component Reference

Page 21

Page 24: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.GetLoadContentType Method

function GetLoadContentType(const Column: String; const RowKey:

String): String

Use this method to retrieve the MIME type for the specified BLOB field in the dataset specified in theDataSet property. The RowKey parameter is a semicolon-delimited (;) list of key values that uniquelyidentify the row that contains the desired BLOB field.

This method is a convenient way of associating MIME types with BLOB fields in a dataset. When thismethod is called, the TEWBDataSetAdapter will look for a field in the dataset with the name of:

<BLOB Field Name>_ContentType

and return its value as the result. If a field does not exist with that name, then the result will be a blankstring.

Component Reference

Page 22

Page 25: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.Initialize Method

procedure Initialize

Use this method to initialize a dataset's key field information. When this method is called, theNumKeyFields, KeyFields, and KeyCaseInsensitive properties are cleared and the OnInitialize event istriggered.

Component Reference

Page 23

Page 26: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBDataSetAdapter.OnInitialize Event

property OnInitialize: TEWBInitializeDataSetAdapterEvent

This event fires when the Initialize method is called, and gives the developer an opportunity to initializethe NumKeyFields, KeyFields, and KeyCaseInsensitive properties of the dataset adapter.

Component Reference

Page 24

Page 27: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

2.3 TEWBMIMEPart Component

Unit: ewbhttpcommon

Inherits From TObject

The TEWBMimePart object is used to represent a single MIME part in multi-part MIME-encoded contentincluded with a web server request. Multi-part MIME content is normally used with HTML form submittalsthat include file uploads.

Properties Methods Events

Content Save

Disposition

Encoding

FileName

Headers

Component Reference

Page 25

Page 28: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEPart.Content Property

property Content: AnsiString

Specifies the content of the MIME part encoded using the encoding specified in the Encoding

Component Reference

Page 26

Page 29: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEPart.Disposition Property

property Disposition: String

Specifies the disposition for the MIME content specified in the Content property. For HTML formsubmittals, this property will always be 'form-data'.

Component Reference

Page 27

Page 30: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEPart.Encoding Property

property Encoding: String

Specifies the encoding for the MIME content specified in the Content property.

Component Reference

Page 28

Page 31: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEPart.FileName Property

property FileName: String

Specifies the file name for the MIME content specified in the Content property.

Component Reference

Page 29

Page 32: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEPart.Headers Property

property Headers: TStrings

Specifies the headers for the MIME part. Each header has the format:

<Header>: <Value>[;<HeaderAttribute>=<Value>]

Component Reference

Page 30

Page 33: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEPart.Save Method

procedure Save(Stream: TStream)

Use this method to save the content specified by the Content property to a stream.

Component Reference

Page 31

Page 34: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

2.4 TEWBMIMEParts Component

Unit: ewbhttpcommon

Inherits From TObject

The TEWBMimeParts object is used to represent all MIME parts in multi-part MIME-encoded contentincluded with a web server request. Multi-part MIME content is normally used with HTML form submittalsthat include file uploads.

Properties Methods Events

Count

Items

Component Reference

Page 32

Page 35: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEParts.Count Property

property Count: Integer

Indicates the number of MIME parts present in the request.

NoteThis number does not include form values that aren't file attachments since they are automaticallymoved to the TEWBServerRequest RequestContentParams property as key-value pairs in order tomake access to such values equivalent to requests that aren't MIME-encoded.

Component Reference

Page 33

Page 36: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBMIMEParts.Items Property

property Items[Index: Integer]: TEWBMIMEPart

Provides access to the MIME parts present in the request by ordinal index.

NoteForm values that aren't file attachments are not included here since they are automatically movedto the TEWBServerRequest RequestContentParams property as key-value pairs in order to makeaccess to such values equivalent to requests that aren't MIME-encoded.

Component Reference

Page 34

Page 37: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

2.5 TEWBModule Component

Unit: ewbhttpmodule

Inherits From TDataModule

The TEWBModule component represents an instance of a registered module in the web server. The webserver automatically creates a new instance of a module for every executing thread and fires theOnExecute event when a new request is handled by the thread. This means that all code in anyOnExecute event handler must be completely thread-safe.

WarningAll modules in the web server run in-process, so a fatal error such as a memory overwrite due toimproper threading code in a module could cause the server to fail.

Properties Methods Events

OnExecute

Component Reference

Page 35

Page 38: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBModule.OnExecute Event

property OnExecute: TEWBModuleExecuteEvent

This event fires when a new request is received by the web server. The request is passed in theTServerRequest parameter to the event.

Component Reference

Page 36

Page 39: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

2.6 TEWBServerRequest Component

Unit: ewbhttpmodule

Inherits From TObject

The TEWBServerRequest object represents a web server request to a module and is passed as aparameter to the TEWBModule OnExecute event. You can use the RequestMethod property to determinewhat type of request is being made, the RequestURLParams property to determine the parameterspassed with the URL of the request, and the RequestContentType, RequestContentLength,RequestContent, RequestContentParams, RequestMIMEParts properties to access content that is includedwith the request:

When the RequestContentType property equals 'application/x-www-form-urlencoded', then thecontent is automatically parsed and moved into the RequestContentParams property.

When the RequestContentType property begins with 'multipart', then the content is automaticallyparsed and moved into the RequestMIMEParts property.

Component Reference

Page 37

Page 40: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Properties Methods Events

RequestChrome DateTimeToGMTStr

RequestContent DateTimeToMSecs

RequestContentLength GMTDateTimeToLocal

RequestContentParams LocalDateTimeToGMT

RequestContentType MSecsToDateTime

RequestCookies SendContent

RequestFirefox SendCustomContent

RequestHeaders SendError

RequestHost SendRedirect

RequestIE

RequestMethod

RequestMethodName

RequestMIMEParts

RequestOpera

RequestParams

RequestPassword

RequestSafari

RequestSecure

RequestURL

RequestURLParams

RequestUser

RequestVersion

ResponseCookies

ResponseHeaders

ResponseSessionCookies

Component Reference

Page 38

Page 41: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestChrome Property

property RequestChrome: Boolean

Indicates whether the client browser is Google Chrome.

Component Reference

Page 39

Page 42: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestContent Property

property RequestContent: AnsiString

Specifies any content sent with the request that is not 'multipart' or 'application/x-www-form-urlencoded'content, as indicated by the RequestContentType property.

Component Reference

Page 40

Page 43: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestContentLength Property

property RequestContentLength: Integer

Specifies the length (in bytes) of the content in the RequestContent property.

NoteFor 'multipart' or 'application/x-www-form-urlencoded' content, as indicated by theRequestContentType property, this property may not accurately reflect the length of theRequestContent property since that type of content is automatically moved to other properties bythe web server.

Component Reference

Page 41

Page 44: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestContentParams Property

property RequestContentParams: TStrings

For 'multipart' or 'application/x-www-form-urlencoded' content, as indicated by the RequestContentTypeproperty, this property will contain any form values submitted from an HTML form that are not fileuploads. The values are specified as key-value pairs in the form:

<Key>=<Value>

Component Reference

Page 42

Page 45: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestContentType Property

property RequestContentType: String

Indicates the type and encoding of the content in the RequestContent property.

Component Reference

Page 43

Page 46: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestCookies Property

property RequestCookies: TStrings

Specifies any cookies that are sent with the request by the client browser. The cookies are specified inkey-value pairs in the form:

<Key>=<Value>

Component Reference

Page 44

Page 47: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestFirefox Property

property RequestFirefox: Boolean

Indicates whether the client browser is Mozilla Firefox.

Component Reference

Page 45

Page 48: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestHeaders Property

property RequestHeaders: TStrings

Specifies all of the raw HTTP headers included for the request.

Component Reference

Page 46

Page 49: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestHost Property

property RequestHost: String

Indicates the value of the 'Host' header in the RequestHeaders property.

Component Reference

Page 47

Page 50: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestIE Property

property RequestIE: Boolean

Indicates whether the client browser is Microsoft Internet Explorer.

Component Reference

Page 48

Page 51: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestMethod Property

property RequestMethod: TEWBRequestMethod

Indicates the type of request.

Component Reference

Page 49

Page 52: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestMethodName Property

property RequestMethodName: String

Indicates the type of request in its raw form.

Component Reference

Page 50

Page 53: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestMIMEParts Property

property RequestMIMEParts: TEWBMIMEParts

For 'multipart' content, as indicated by the RequestContentType property, this property will contain anyMIME content that aren't textual form values.

Component Reference

Page 51

Page 54: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestOpera Property

property RequestOpera: Boolean

Indicates whether the client browser is the Opera web browser.

Component Reference

Page 52

Page 55: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestParams Property

property RequestParams: TStrings

Indicates the URL parameters for the request as key-value pairs in the form:

<Key>=<Value>

Component Reference

Page 53

Page 56: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestPassword Property

property RequestPassword: String

Indicates the value of the 'X-EWB-Password' header in the RequestHeaders property. This header isnormally sent by Elevate Web Builder applications for dataset requests, but can be used for other typesof requests also.

Component Reference

Page 54

Page 57: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestSafari Property

property RequestSafari: Boolean

Indicates whether the client browser is Apple Safari.

Component Reference

Page 55

Page 58: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestSecure Property

property RequestSecure: Boolean

Indicates whether the request is secure (HTTPS) or not.

NoteThe web server does not currently support secure requests.

Component Reference

Page 56

Page 59: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestURL Property

property RequestURL: String

Indicates the URL of the request without any URL parameters. The URL parameters can be retrieved viathe RequestURLParams (raw) or RequestParams (key-value pairs) properties.

Component Reference

Page 57

Page 60: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestURLParams Property

property RequestURLParams: String

Indicates the URL parameters for the request in their raw form. Use the RequestParams property toaccess the URL parameters as key-value pairs.

Component Reference

Page 58

Page 61: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestUser Property

property RequestUser: String

Indicates the value of the 'X-EWB-User' header in the RequestHeaders property. This header is normallysent by Elevate Web Builder applications for dataset requests, but can be used for other types ofrequests also.

Component Reference

Page 59

Page 62: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.RequestVersion Property

property RequestVersion: String

Indicates the HTTP version in use by the client browser, and is usually 'HTTP/1.1'.

Component Reference

Page 60

Page 63: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.ResponseCookies Property

property ResponseCookies: TStrings

Use this property to specify any persitent cookies that you want to add/modify in the client browser.

Component Reference

Page 61

Page 64: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.ResponseHeaders Property

property ResponseHeaders: TStrings

Use this property to specify any special response headers that you want to send to the client browser. Bydefault, the following methods automatically send the indicated response headers:

Method Headers Sent

SendContent 'Date''From''Server''Connection''Content-Type''Content-Length'

SendCustomContent 'Date''From''Server''Connection''Content-Type''Content-Length''Content-Disposition'

SendRedirect 'Date''From''Server''Connection''Content-Type''Content-Length''Location'

SendError 'Date''From''Server''Connection''Content-Type''Content-Length'

In addition, any cookies specified in the ResponseCookies or ResponseSessionCookies are automaticallysent using a 'Set-Cookie' header.

Component Reference

Page 62

Page 65: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.ResponseSessionCookies Property

property ResponseSessionCookies: TStrings

Use this property to specify any session-only cookies that you want to add/modify in the client browser.Session-only cookies only persist until the client browser session terminates, and then are cleared by thebrowser.

Component Reference

Page 63

Page 66: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.DateTimeToGMTStr Method

function DateTimeToGMTStr(Value: TDateTime): String

Converts a TDateTime value into a GMT date/time string that adheres to RFC1123 and has the format:

dow, day month year hours:mins:secs GMT

Component Reference

Page 64

Page 67: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.DateTimeToMSecs Method

function DateTimeToMSecs(Value: TDateTime): Int64

Converts a TDateTime value into the number of milliseconds since midnight, January 1, 1970.

NoteThe result is the native date/time representation used by JavaScript and Elevate Web Builderclient applications.

Component Reference

Page 65

Page 68: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.GMTDateTimeToLocal Method

function GMTDateTimeToLocal(Value: TDateTime; IncludeDST:

Boolean=True): TDateTime

Converts a GMT (UTC) TDateTime value into its local equivalent, optionally accounting for DaylightSavings Time.

Component Reference

Page 66

Page 69: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.LocalDateTimeToGMT Method

function LocalDateTimeToGMT(Value: TDateTime; IncludeDST:

Boolean=True): TDateTime

Converts a local TDateTime value into its GMT (UTC) equivalent, optionally accounting for DaylightSavings Time.

Component Reference

Page 67

Page 70: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.MSecsToDateTime Method

function MSecsToDateTime(Value: Int64): TDateTime

Converts the number of milliseconds since midnight, January 1, 1970 into a TDateTime value.

NoteThe input is the native date/time representation used by JavaScript and Elevate Web Builderclient applications.

Component Reference

Page 68

Page 71: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.SendContent Method

procedure SendContent(const Content: String; StatusCode:

Integer=HTTP_OK; const StatusMessage: String='')

Sends a response to the client browser using the passed content, HTTP status code, and status message.The Unicode content is automatically sent in UTF-8 format. Please see the following link for a completelist of HTTP status/error codes:

Status Code and Reason Phrase

NoteOnly one response can be sent per request. Attempting to send more than one response willcause errors in the client browser.

Component Reference

Page 69

Page 72: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.SendCustomContent Method

procedure SendCustomContent(const Content: String; const

ContentType: String; const ContentDisposition: String)

procedure SendCustomContent(const Content: AnsiString; const

ContentType: String; const ContentDisposition: String)

Sends a response to the client browser using the passed content, type, and disposition.

NoteOnly one response can be sent per request. Attempting to send more than one response willcause errors in the client browser.

Component Reference

Page 70

Page 73: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.SendError Method

procedure SendError(ErrorCode: Integer; const ErrorMessage:

String)

Sends an error response to the client browser using the passed HTTP error code and message. TheUnicode message is sent as the content in UTF-8 format. Please see the following link for a complete listof HTTP status/error codes:

Status Code and Reason Phrase

NoteOnly one response can be sent per request. Attempting to send more than one response willcause errors in the client browser.

Component Reference

Page 71

Page 74: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

TEWBServerRequest.SendRedirect Method

procedure SendRedirect(const NewLocationURL: String; const

Content: String=''; StatusCode: Integer=HTTP_FOUND; const

StatusMessage: String='Redirecting')

Sends a redirect response to the client browser using the passed new location, content, HTTP statuscode and message. The Unicode content is automatically sent in UTF-8 format. Please see the followinglink for a complete list of HTTP status/error codes:

Status Code and Reason Phrase

NoteOnly one response can be sent per request. Attempting to send more than one response willcause errors in the client browser.

Component Reference

Page 72

Page 75: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

Chapter 3Type Reference

3.1 TEWBGetDataSetAdapterEvent Type

Unit: ewbdatasetadapter

TEWBGetDataSetAdapterEvent = procedure(const DataSetName: String;

var Adapter: TEWBDataSetAdapter) of object

This type is used for the TEWBDatabaseAdapter OnGetDataSetAdapter event.

Type Reference

Page 73

Page 76: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

3.2 TEWBInitializeDataSetAdapterEvent Type

Unit: ewbdatasetadapter

TEWBInitializeDataSetAdapterEvent = procedure(Adapter:TEWBDataSetAdapter) of object

This type is used for the TEWBDataSetAdapter OnInitialize event.

Type Reference

Page 74

Page 77: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

3.3 TEWBModuleExecuteEvent Type

Unit: ewbhttpmodule

TEWBModuleExecuteEvent = procedure (Request: TEWBServerRequest)of object

This type is used for the TEWBModule OnExecute event.

Type Reference

Page 75

Page 78: Elevate Web Builder Modules ManualElevate Web Builder manual that comes with the Elevate Web Builder IDE. These sections contain important information such as how server requests work

3.4 TEWBRequestMethod Type

Unit: ewbhttpmodule

TEWBRequestMethod = (rmUnknown,rmGet,rmPost,rmHead,rmPut,rmDelete)

This type is used to represent the type of request in the TEWBServerRequest RequestMethod property.

Element Description

rmDelete The request is an HTTP DELETE request (not supported bythe web server for modules at this time).

rmGet The request is an HTTP GET request.

rmHead The request is an HTTP HEAD request (not supported by theweb server for modules at this time).

rmPost The request is an HTTP POST request.

rmPut The request is an HTTP PUT request (not supported by theweb server for modules at this time).

rmUnknown The request is an unknown HTTP request (not used by theweb server for modules - an error will occur before themodule is called if the request type is unknown).

Type Reference

Page 76