The RunData Object is referenced by the "data" keyword, which when using this
in the templating system is referenced by $data. As the Context contains a link
to the RunData object all the public methods in the RunData Object are made
available to the template. For example, typing $data.getMessage() will access
the message String being stored in the RunData Object and print that as part
of the templates output.
RunData exposes an extremely rich series of methods and fields, for a full list
of these methods refer to the Javadocs for RunData. Some of the useful methods
exposed in RunData include;
addMessage(String msg)
getMessage()
getParameters()
getServerName()
getTitle()
getUser()
removeUserFromSession()
setMessage(String message)
setRedirectUri(String ruri)
setTitle(String title)
The RunData also allows for access to the TemplateInfo Object via
getTemplateInfo() and several convenience methods. This allows for properties
of the Templates to be modified for a Request when using templating systems like
Velocity, WebMacro or Freemarker.
As an example assume we want a printable page that contains only the Templating
Screen and not all the navigational components. To achieve this we can strip
out all the non screen templating components by describing a new Layout Template
called PrintableLayout.vm in the templates/layouts directory. All the
PrintableLayout needs contain is;
Without the references to the $navigation.setTemplate() methods in the template
no navigational screen will be called. In the Screen Template that wants to take
advantage of the PrintableLayout Template add to the Template;
 |
 |
 |
 |
$data.setLayoutTemplate("/PrintableLayout.vm")
|
 |
 |
 |
 |
This will strip the Screen Template of its Navigational components. These
convenience methods can also be used to expose and to set the Layout when the
Template is processed. Through this a User can potentially choose how they would
like their webpage to appear by choosing one of many differant Layouts or
choices you, the webdesigner provide.
Currently the setLayoutTemplate(), getLayoutTemplate(), setScreenTemplate() and
getScreenTemplate() methods arent available in TDKa9. Until the next build of
the TDK contains RunData with those methods, the setLayoutTemplate method can
still be accessed through the TemplateInfo Object that RunData exposes.
For example;
 |
 |
 |
 |
$data.getTemplateInfo().setLayoutTemplate("/PrintableLayout.vm")
or
#set $template = $data.getTemplateInfo()<br />
$template.setLayoutTemplate("/PrintableLayout.vm")
or
#set $template = $data.getTemplateInfo()<br />
$!template.setLayoutTemplate("/PrintableLayout.vm")
|
 |
 |
 |
 |
In the third example, the ! stops the echo of the Velocty Directive echoing to
screen.