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

setMimeType()

Set the mime-type that should be returned with the output of this page.

Syntax

void = rb.page.setMimeType(mimeType)

Parameters

The 'setMimeType' method takes 1 parameter:

Name Type/Value Range/Length Description
mimeTypestring  Required. Mime type the the page wishes to send back to the browser.

Results

The 'setMimeType' method returns no useful information.

Remarks

The main primary of the Presentation Engine is to generate dynamic page context to be sent to a client browser. When content is sent to a browser a 'Mime Type' is sent as well. The mime type is used by the browser to determine how to present the data to the user. Most Pattern Pages generate HTML - the default Web language. By default the Presentation Engine sends an appropriate mime-type for HTML and there is no need for the web author to change this.

There are however occassions when a presentation page needs to send non-HTML data. Sometimes this can be binary form data - such as a GIF - or some data for a specific application, such as a spreadsheet. This can obviously be sent directly by the web server simply by referencing the relevant file name on the server. But that solution does not allow the web site auther to apply any intelligent processing to service the request. Instead it is useful to generate a Whitebeam Pattern Page that outputs the correct file after, for example, applying a set of authentication rules.

In these situations the web author must tell the presentation engine the type of data being returned to the client. This is achieved through the 'rb.page.setMimeType' method.

Not all browsers correct interpret the mime-type returned by the server and instead try to infer the type of data from the filename extension. For this reason it is necessary for the web author to arrange for the URL requested by the browser to have a suitable extension. When you try to do this though note that only URLs with an extension of 'rhtm' are executed by the Presentation Engine. To get around this reference the URL then append a name with the correct extension. So for example to output a reference to '/site/get_PDF_file.rhtm', that actually returns a pdf file use a dummy URL of '/site/get_PDF_file.rhtm/dummy.pdf'.

Example

The following very simple example returns the a GIF based on extracting the required gif file-name from the 'pathinfo' passed from the client. So for example if this example is '/getgif.rhtm' a browser can request '/getgif.rhtm/pict.gif' and the path-info will be 'pict.gif. The file authenticates the user before allowing access to the gif.

<rb:authenticate domain="DocLibrary" community="WWWUsers">
   <rb:script>
      var image = new Binary;

      // Load the binary image from the file system
      var Fname = rb.page.env.PathInfo();
      image.fname(Fname);
      if (!image.load()) {
         // File not found - send the default image.
         image.load("/default.gif");
      }
      // Set the mime-type to be suitable for a GIF.
       rb.page.setMimeType("image/gif");
      rb.page.writeraw(image);
   </rb:script>
</rb:authenticate>
Whitebeam release 1.3.36
(loadtime : 111ms)