Mozilla Skin

Javadoc

From GTwM

Contents

Writing agileBase templates

Introduction

The GUI interfaces with the server by using the API described in the JavaDoc linked to at the bottom of the page. There is one main entry point

DataManagement.ViewMethods

which can be accessed from the Velocity templating language with the variable $view.

DataManagement.SessionData data can be accessed from $session.

DataManagement.ViewTools is also available as $viewTools. This provides utility methods that don't directly access portalBase data but perform other services, for example checking if a particular template exists or converting a currency into words. New methods are added to ViewTools as required by template designers.

Most of the time, view methods return agileBase objects, e.g. getTable returns a TableInfo object. These agileBase objects will in turn have many methods that can be called on them, frequently returning other objects, e.g. TableInfo.getDefaultReport() returns an object representing a report. In other words, you can walk through a 'tree' of objects by calling methods on them.

To get a report field:

 $view.getTable("organisations").getReport("all organisations").getReportField("website address")

To see information about the object that a method returns, there is a link to the returned object type to the left of the method name.

Objects can be identified either by name or by internal ID. Names are useful when quickly prototyping some templates. It's better to move to IDs in the long run as when you change a name, the ID remains the same, ensuring you don't have to edit any templates that use the object.

Note, many objects contain methods that make some change to the object, often called 'setter' methods because they begin with the word set. These aren't meant for use in templates.

Examples

Some example functions for use in Apache Velocity templates

Show the logged in user and the name of their organisation

 User logged in: $view.getLoggedInUser() belongs to 
 company: $view.getLoggedInUser().getCompany()

Check whether the current user has a particular privilege

 #set($organisationsTable = $view.getTable("organisations"))
 #if($view.loggedInUserAllowedTo("VIEW_TABLE_DATA", $organisationsTable))
   User has view privileges on $organisationsTable
 #else
   User is unable to view $organisationsTable
 #end

Check whether a field object is it's table's primary key

 #if($field.getTableContainingField().getPrimaryKey().equals($field))
   $field is the identifier
 #end

Retrieve all data in the current record the user is viewing

 #set($tableDataRow = $view.getTableDataRow())
 #foreach($field in $tableDataRow.keySet())
   Value of $field is $tableDataRow.get($field). 
 #end

Retrieve all the data in a particular report

 #set($reportBaseFields = $report.getReportBaseFields())
 #set($reportDataRows = $viewMethods.getReportDataRows($report))
 #foreach($reportDataRow in $reportDataRows)
  <tr>
      #foreach($field in $reportBaseFields)
        <td>
          $reportDataRow.getValue($field).getDisplayValue()
        </td>
      #end
    #end
  </tr>
 #end

Retrieve a selected set of columns in a particular report

 #set($reportDataRows = $view.getReportDataRows($report))
 #foreach($reportDataRow in $reportDataRows)
  <tr>
    <td>$reportDataRow.getValue("name")</td> 
    <td>$reportDataRow.getValue("phone number")</td> 
    <td>$reportDataRow.getValue("email address")</td> 
  </td>
 #end

Retrieve some session details

 The current table is $session.getTable(), report $session.getReport(), row ID $session.getRowID()

Full Javadoc for agileBase

$view methods: http://agilebase.co.uk/static_features/javadoc/com/gtwm/pb/model/interfaces/ViewMethodsInfo.html

$session methods: http://agilebase.co.uk/static_features/javadoc/com/gtwm/pb/model/interfaces/SessionDataInfo.html

Complete API: http://agilebase.co.uk/static_features/javadoc/