Whitebeam Script

Site Map
 
Home
 
Application Guide
Reference
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Script

Whitebeam Script Language
Whitebeam Object Model

Contents 


Overview 

In the Whitebeam architecture the user interface is generated by a set of 'Presentation Pages'. The Whitebeam System uses these presentation pages to dynamically generate the HTML pages that an end-user sees at a Web Browser. There are many potential ways in which this dynamic server-side behaviour can be achieved, common examples include various scripting languages such as Perl and Tcl/Tk or binary executables using the Common Gateway Interface (CGI). The Whitebeam system uses a mixture of additional XML tags and Server-Side JavaScript. The JavaScript language is identical to that supported on the Client Side in common browsers such as NetScape and Internet Explorer reducing the learning curve for Integration Partners

JavaScript provides a basic syntactical and sematic structure for controlling flow of execution and for generically accessing user defined application programming interfaces (API). By itself the language definition doesn't really do anything. To be useful an application has to have a way of using the language to interract with an underlying system. In client side JavaScript this is achieved through a Document Object Model (DOM). The Whitebeam system defines a similar object model, called the 'Whitebeam Object Model'. The object model defines a set of 'standard' methods and sub-objects that are always available along with a set of definitions that are specific to the business templates being used by the client. This document describes the core (always present) elements of the Whitebeam Object Model. 

The following core definitions always exist. 

rbTop level Whitebeam object. This is the anchor for all the other Whitebeam objects.
rb.pageThis object represents information and control of the HTML page being generated by the Presentation Engine.
rb.page.attribute()Return the value of a named attribute from the tag containing the script being executed. This method is primarily targetted at the implementation of tags (using the <rb:macrotag...>).
rb.page.attributes()Creates a JavaScript object containing properties representing each of the attributes in the currently executing tag.
rb.page.formdata()This method returns the post data that accompanied the HTTP request.If the HTTP method was not 'POST' then this wll return an empty string. Post data returned from this method is not decoded in any way by the Rebourne infrastructure.
rb.page.getHeader()Return a named HTTP header, if present. If found the method returns the raw text from the header. Name is not case sensitive.
rb.page.iterateHeader()Create an 'iterator' that allows the Whitebeam Script to step over each of the defined HTTP headers.
rb.page.postdata()Create a JavaScript object that contains properties for each parameter passed to the page. This works for 'GET' and 'POST' methods and the value of the properties created are URL decoded (no strange escape sequences to deal with!).
rb.page.redirect()Causes the presentation to discark all output generated by this page and after processing the page to load instead another page within the clients virtual server. This is effectively a server-side redirection to a different page.
rb.page.setMimeType()Set the 'mime-type' for the page being generated.
rb.page.tagtree()This method creates a JavaScript array object containing an entry for each of the XML elements (except comments) within the body of the tag currently executing. Those elements that are themselves tags contain an array of elements etc. This is only useful in JavaScript within an <rb:macro...> definition and allows the implementation of complex psuedo tags such as <tree...><treelem...> etc.
rb.page.write()Output a string to the target page (e.g. effectively writes to the remoate browser).
rb.page.writeheader()Writes an HTTP header. Two parameters specify the name of the header and the contents for the header. Both are strings.
rb.page.writeraw()Writes an HTTP header. Two parameters specify the name of the header and the contents for the header. Both are strings.
rb.page.cookieObject that encapsulates access to incoming cookies (from a browser) and allows the writing of outgoing cookies.
rb.page.cookie.delete()Delete a cookie from the browser. This writes the cookie with an expiry date in the past and a Max-Age of zero (0).
rb.page.cookie.read()Create a JavaScript object containing all the cookies received from the browser. Each cookie is represented as a named property of the object created, the name being that provided by the cookie. The value of each property is then the provided value of the cookie.
rb.page.cookie.write()Write a cookie to the browser. There are two mandatory parameters, the name of the cookie and the value. The framework correctly escapes the value so there is no need to do this in the script. Additional parameters allow control of the path, domain etc attributes of the cookie. 

Multipe 'writes' of the same name overwrite each other.

rb.page.envProvides a similar set of data to that provided in environment variables in a cgi application.
rb.page.env.ServerName()
rb.page.env.ServerSw()
rb.page.env.ServerProtocol()
rb.page.env.ServerPort()
rb.page.env.RequestMethod()
rb.page.env.PathInfo()Additional information in the path part of the URL that was now required to locate the resource.
rb.page.env.QueryString()
rb.page.env.RemoteHost()
rb.page.env.RemoteAddr()
rb.page.env.Path()The local (virtual server relative) path name of the resource requested by the client browser. If the page is being generated as the result of a server-side redirection _then_ the path will specify the original page actually requested.
rb.page.env.UserAgent()
rb.page.env.Referer()
rb.page.env.ProxyConnection()
rb.page.env.RemoteUser()
rb.page.sessionProvides access to Whitebeam session specific data. The context mechanism allows integration partners to write parameters to a semi-permanent server-side store and to retrieve those parameters on subsequent page requests.
rb.page.session.read()Read the contents of the server side 'context'.
rb.page.session.write()Make changes to the context permanent so they can be retrieved on a subsequent page access.
rb.page.session.id()Return the server generated 'context id'. This value is automatically created by the Whitebeam system when a page is accessed. It is used to distinguish a browser session from other such sessions and provides the presentation page with a key by which it can access a store of server stored information associated with the session.
rb.page.session.url()Tracking 'context' is fairly difficult in HTML. The Whitebeam system automatically makes used of client side cookies to store tracking information. If clients have cookies disabled however this doesn't work. Alternatives are more complex by are supported by the Whitebeam system. This method provides a means of embedding a context token within a URL, for example within a hot-link.
rb.debugThis branch of the object model is focussed on providing tools to help integration partners develop and deliver their web applications. This branch will be expanded as more facilities become available.
rb.debug.write()This method generates output in a similar way to rb.page.write(). In this case however the text written is not automatically part of the page being generated. Instead is is only displayed on the Whitebeam error page or by inserting <rb:insertdebug/> tag into the text
rb.debug.mode()The debug mode determines whether calls to rb.debug.write are ignored. By default running a page in the active instance causes all rb.debug.write calls to be ignored. In the test instance they are not. This allows debug mode to be enabled in the active instance for problems that can't be reproduced


Status and Error Conditions 

The interface to each template is described individually. Each template is characterised by an API held within a portion of the Rebourne Object Model. The API description describes for each method what parameters are expected and what error conditions can occur. The Whitebeam architecture provides a fairly generic status reporting mechanism that can be used by the templates, this mechanism is the subject of this section. 

The 'Whitebeam' object (rb) has a property called status. By default this contains the value 'rb.rb$ok' - a non-error condition. Each method may write a status value to this property that can then be inspected by the javascript presentation page. Note though that one page cannot overwrite an error condition with rb.rb$ok. This allows several Rebourne calls to be made and then one check of the status to make sure that there were no exceptional conditions. 

In conjunction with the status value, which is numric, there are two textual properties: rb.statusString - a short textual name for the status condition; rb.statusDesc - a slightly longer description of status condition. The latter is useful for displaying in a debug error message. 

Summary: 

rb.statusThe last recorded error condition.
rb.statusStringThe textual name of the error status.
rb.statusDescA short explanation of the condition.

Note that not all status conditions are necessarily fatal. If, having dealt with a status condition, a page wishes to continue processind the page then the status can be cleared by writing rb.rb$ok to it. 

Each template describes those error conditions it is capable of generating in terms of 'status' values. Status values are properties of one of the objects in the Rebourne Object Model - usually the top level object provided by a particular template. Each has a symbolic name.

The value of 'rb.status' can be simply compared with rb.rb$ok - NOT being this value imlies some exceptional condition in one of the template calls.

Alternatively 'rb'status' can be compared against specific status values. Each defined status value exists as a property of a Whitebeam object, and the property name always starts with rb$.

Example. Consider a template that implements 'rb.shop' as its top level branch of the Whitebeam object model. This template exports the following status values that can be used by it's methods to convery status information to the presentation pages:

NameDescription
notAvailable

Template is NOT currently active

tooBigClient file exceeded template restrictions on size
tableFullNo more space in template table
accessDeniedClients authorisation insufficient for operation.

A typical way for these status values to work is for a modify method to return a simple success status to the caller and if the operation fails to provide additional information n the status property - rb.status.

The template exports a method called 'rb.shop.addInventory'. The method looks like:

bool rb.shop.addInventory(productName, quantity, image)

The method returns 'true' if it works OK, otherwise it returns 'false' and sets the reason in the status value. Whitebeam script could then access this method in the following way:

if (!rb.shop.addInventory("Widget", 500, imagegif)) {
   rb.page.write('<p>Failed to update inventory');
}

Alternatively a presentation page may choose to provide more specific error messages by lookng at the rb.status property as follows:

if (!rb.shop.addInventory("Widget", 500, imagegif)) {
   switch (rb.satus) {
   case rb.shop.rb$notAvailable:
      rb.page.write('<p>Template not available');
      break;
   case rb.shop.rb$tooBig:
      rb.page.write('<p>Inventory size is too big');
      break;
   case rb.shop.rb$tableFull:
      rb.page.write('<p>Template table is full');
      break;
   case rb.shop.rb$accessDenied:
      rb.page.write('<p>You may <b>not</b> do that!');
      break;
   }
}

The presentation page may also output the generic - template generated name and description of the status condition. This is useful during development and testing of presentation pages. A fairly generic

Whitebeam release 1.3.36
(loadtime : 11ms)