A template is a file that contains instructions on how to produce
a generated file
using the information from a
project as input. Template
files are identified by a .ftl
suffix and are processed
using the FreeMarker (
) template engine.
The name of a template is taken from the name of the file that contains it.
A template must be located in a directory determined by concatenating the template's category and type.
For example, a template with a category of databases/hsqldb/1.7
and a type of database
, must be located in the directory
databases/hsqldb/1.7/database
.
The format of a template file is described here.
The data model contains the information that is available to a template when it is processed.
More information about the data model can be found here.
Generic templates should be used to produce files that do not have additional requirements outside those of the default generated application. Similarly, non-generic templates should be used to produce files that are specific to a requirement that is outside the basic requirements for the application. For example, generic templates could be used to produce files that work under all versions of Java. Non-generic templates could be used to produce files that are dependent on the version of Java being used.
Non-generic templates take precedence over generic templates when producing files. However when two non-generic templates attempt to produce the same file, RapidJ will display an error indicating that it cannot choose between two non-generic templates.
The type specifies which part of a project the template produces files for. The following types are available:
![]() |
application - indicates that the template may produce a single file for a project |
![]() |
entity - indicates that the template may produce a file for every entity in a project |
![]() |
guiComponent - indicates that the template may produce a file for each GUI component in a project |
![]() |
database - indicates that the template can be used to produce a database script for a project |
![]() |
other - all other types are not directly used to produce files. They may be included by other templates. |
When a template is disabled, it will be ignored by the generator. By disabling the non-generic templates that are not required for your particular application you will be able to reduce the number of files that are generated, and hence the time taken to generate.
Template errors can be classified into three main types:
Type | Description |
---|---|
Header errors | These occur when the template header is not in the correct format. |
Parse errors | These occur when the syntax of the template body is incorrect. |
Generation errors | These can occur for many reasons, but generally they happen when a template incorrectly tries to access the template data model. |
Project
Generated file
Template format
Template data model
Customising a template
Disabling/enabling templates
Creating new templates