Home

 

Templates

A template is a convenience that allows the programmer to quickly insert often reoccurring source code patterns. Application Developer has pre-defined templates and allows you to create new and edit existing templates.

The templates can be used by typing a part of the statement you want to add; and then by pressing Ctrl+Spacebar in the Java editor, a list of templates matching the key will appear in the presented list. Note that the list is filtered as you type, so typing the few first characters of a template name will reveal it.

The symbol in front of each template , in the code assist list is colored yellow, so you can distinguish between a template and a Java statement entry.

Figure 3-32 Using templates for content assist

To configure templates, select Windows Æ Preferences Æ Java Æ Editor Æ Templates .

Figure 3-33 Java Editor: Templates preferences

Click New to add a new template and, for example, enter the information to create a new template for a multi-line if-then-else statement, and click OK .

Figure 3-34 Creating a new template

The template is now available for use in the Java editor.

There are also some predefined variables available that can be added in the template. These variables can be inserted by clicking Insert Variable. This brings up a list and a brief description of the variable.

Templates that have been defined can be exported and later imported into Application Developer to ensure that a common environment can be set up among a team of developers.

ibm.com/redbooks