Whitebeam Template Reference Documentation

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Template Reference Documentation

System Template

formdata()

Access parameters passed to the Presentation Page from a remote Web Browser.

Syntax

MetaData Object = rb.page.formdata(interpretCharset)

Parameters

The 'formdata' method takes 1 parameter:

Name Type/Value Range/Length Description
interpretCharsetbool  Optional, default = true
Mime type the the page wishes to send back to the browser.

Results

The method creates a JavaScript object. The object contains a JavaScript property for each of the parameters passed to the page from the browser. The Whitebeam System Template transparently extracts parameter values from both GET and POST methods - no special behaviour is required from the presentation page.

Each parameter is represented in the returned object as a named parameter. The name of the property matches the name of the parameter passed from the end-users browser. The property is represented by either a string or an array according to the following rules:

  • If the name of the parameter ends with [] then the brackets are removed from the name and the parameter is always represented as an array. For example a parameter called choices[] will be mapped to a JavaScript property choices that will be an array of one or more elements
  • Where the name of the parameter does em end with [] Whitebeam will create a string property if there is exactly one parameter with that name, otherwise it will create an array containing each of the values of that parameter

By default the system assumes the text in the post data is LATIN-1 characters.

If the optional interpretCharset parameter is specified and is true then Whitebeam will interrogate the HTTP headers to determine the character set. If UTF-8 is specified then the UTF-8 characters are correctly expanded into JavaScript.

NOTE: interpretCharset should probably be set to true for all cases and this may become the default in future Whitebeam Whitebeam releases.

Type/Value Range/Length Description
MetaData  This method provides access to parameters passed to the Presentation Page from a remote Web Browser (an end-user).

Remarks

The will decode parameters passed on the URL using standard HTTP encoding. It will also successfully decode parameters from POST methods provided the HTTP Content-Type header has a value of application/x-www-form-urlencoded. This is the usual encoding for HTTP forms. If this processing is insufficient then the application can use the rb.page.postdata method to process the raw encoded post data.

Processing form items from multi-select list boxes is slightly complicated. In this situation one of the following conditions will apply to the form data object:

  • If no items are selected there will be no property in the form-data object.
  • Where a single item has been selected the object will contain a JavaScript 'String' object containing the selected item.
  • Where more than one item has been selected the form-data object will contain a javaScript 'Array' object. Each of the selected values will be present in the array.
This can be processed in the Pattern Page as follows:
var fd = rb.page.formdata();
// process 'listvals' - data from a multiselect list box.
if (fd.listvals) {
   // Something selected - one or more items?
   if (typeof fd.listvals=="Array") {
      // More than one thing selected - each is an array element.
         ...
      }
   else {
      // More than one thing selected - each is an array element.
      ...
   }
}

Example

var parameters = rb.page.formdata();

rb.page.write("<table>\n");
for (aParameter in parameters) {
   rb.page.write("<tr><td>Parameter Name="+aParameter+"</td><td>Cookie Value="+parameters[aParameter]+"</td></tr>\n");
}
rb.page.write("</table>\n");
Whitebeam release 1.3.36
(loadtime : 71ms)