Whitebeam Object Definition

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 Object Definition

Method Description

XmlGeneric.execute()

Re-execute part of an XML tag tree. ADVANCED.

Syntax

XmlGeneric.XmlGeneric = XmlGeneric.execute(parameters)

Parameters

The 'XmlGeneric.execute' method takes 1 parameter:

Name Type/Value Range/Length Description
parametersMetaData  Optional. JavaScript parameters to be passed to the tagtree. These appear as global JavaScript variables to any JavaScript executed within the tag-tree.

Results

The 'XmlGeneric.execute' method returns structure:

Type/Value Range/Length Description
struct XmlGeneric.XmlGeneric see definition

Remarks

The Presentation Engine re-executes the XML sub-tree rooted at the selected branch. Invoking this method will discard the current text output of the tag tree and rerun the entire subtree. In the case where the tag tree simply contains static HTML - this will generate the same text. Where the tree contains active server-side code however that code will be re-executed using the current executing environment. So for example macro tags defined within XmlParser that contains the tag will be executed.

The tag tree re-executed may include content that executes JavaScript - either directly through things like the <rb:script...> or <rb:eval...> tags, or indirectly because the content includes a tag for which there is a macro tag definition - an <rb:macrotag...>. In these situations it can be useful to pass some parameters into the tagtree. Consider the very simple example:

<rb:block rb:id="myBlock">
   <tr>
      <td>
         <rb:eval expr="name"/>
      </td>
      <td>
         <rb:eval expr="dataset[name]"/>
      </td>
   </tr>
</rb:block>

<rb:script>
   var data = ["this", "is", "the", "dataset"];
   var tags = rb.xml.findId("myBlock");

   for var (count=0;count<data.length;count++) {
      tags.execute();
      rb.page.write(tags.toString());
   }
</rb:script>

In this case we want to repeat the block a number of times - each time the code generates a different table row. The example won't work because the contents of the tagtree is always executed in the global context. To make this work you have to pass the parameters into the execution. Re-writing the script yields the correct behaviour:

<rb:script>
   var data = ["this", "is", "the", "dataset"];
   var tags = rb.xml.findId("myBlock");

   for var (count=0;count<data.length;count++) {
      tags.execute({count:count, dataset:data});
      rb.page.write(tags.toString());
   }
</rb:script>

'regenerate' now has a single parameter - an object that is initialised to contain two attributes, 'count' and 'dataset'. This object is placed at the front of the JavaScript scope chain before executing the XML subtree.

Whitebeam release 1.3.36
(loadtime : 11ms)