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

write()

Write dynamic content to the browser.

Syntax

void = rb.page.write(output_data, ...)

Parameters

The 'write' method takes 2 parameters:

Name Type/Value Range/Length Description
output_datastring  Required. The string to be written to the client browsers.
...string  Optional. additional strings.

Results

The 'write' method returns no useful information.

Remarks

This method allows the Presentation Page to write dynamic content to the page being generated for the end-users browser. This is the primary way that a Pattern Page writes content to the browser. The parameters to the call are one or more strings. e.g.

rb.page.write('hello',' ', 'world')

Passing 3 parameters such as ('a', 'b', 'c') is preferable to concatenating the strings and passing a single parameter. If the former case all the strings are concatenated together in one action - which is more efficient!

The write() method writes content to the output page being generated. In execution terms the <rb:script...> tag is replaced with the output generated by all of the rb.page.write() calls within the tag. Although this method takes exactly one parameter it is commonly used with a sequence of strings concatentated together.

The parameter list may contain any JavaScript type that supports 'toString()' behaviour - that is almost any type! The normal behaviour of the Presentation Engine is to take the value - if it is a string it is simply written into the output being accumulated. If the value is not a string then the 'toString()' method is called on the value and whated the result of that operation is sent to the page under construction.

The exception is the case where the parameter is a binary object. In this case the contents of the binary object are written directly to the output stream, bypasing the XML processing of the page. The data is sent immediately to the browser and the data generated by the XML parsing itself - if any - is discarded.

The behaviour when calling this method with a binary object is identical to that of calling rb.page.writeraw.

Example

<rb:script>
   var text = "Hello World";

   rb.page.write("<h1>"+text+"</h1>\n");
</rb:script>

This will replace the <rb:script> tag with the text
   <h1>Hello World </h1>

Whitebeam release 1.3.36
(loadtime : 61ms)