Useful Tools, Include Files and Code Fragments


This is a miscellaneous collection of different items that you might find useful. Selecting the view/download link opens a browser window with the source code visible and a button to download the file to your workstation.




This is a simple include file that is used to print out details of any data structure to the debug stream in the form of a table. It provides a function dumpObj(obj, prefix) (that calls a recursive function dumpRow() ) that takes two parameters:

obj - any JavaScript object
prefix - a text string to prepend to each property of the object when its displayed

Include the file using <rb:include src="pathname/" />

dispcode.rhtm This is the file that the example pages use to display the source of any page on a browser screen rather than the interpreted HTML. The file to display is passed as a parameter with the name of "file" e.g. set up a link with the following: dispcode.rhtm?file=pathname/filename.ext This file works by creating a Binary object (this is a special object type together with a set of associated methods predefined by the Redbourne system ), loading the file passed as a parameter into the Binary and wrapping the output with HTML< xmp> tags.
image.rhtm This pattern page outputs a gif or jpeg image stored in the database. The file is identified by the fileID appearing as path information after image.rhtm. i.e. in the requesting page the HTML tag looks like <img src="images/image.rhtm/456.gif">. When the browser loads the file it sends a request to images/image.rhtm, the 456.gif part appears as path information which is extracted and used to get the file from the file template which stores it on the database. If no file exists a default file (called default.gif or default.jpeg) located in the images directory is served instead.
csvupload.rhtm This is some example code that decodes a CSV file supplied as a file type form variable. Typically it might be used to upload data into one of the templates (such as catalogue). This is just a skeleton, it has no HTML and no destination for any processed data.
mail.rhtm This code example shows how to generate an e-mail based on form input. The page assumes the form posts variables "message" and "emailAddress" which are used as the body and sender e-mail address respectively. A useful concept (used in the Redbourne website) is that the destination addresses of the e-mail are generated based on a the members of a specified community held in the Contacts template. This allows the Client to simply change who in their organisation gets the e-mail using a suitable contacts management application without getting their Channel Partner to modify the pattern pages.