Template Components
Templates
Template Management
The contents of the Create New panel are determined by template definition files that are present in your environment. Each workspace uses two template definition files:
- A system template definition file, located in the system config directory (e.g.,
C:\Program Files\DataFlex\pkg\config\templates.xml). - A workspace template definition file, located in your primary
appsrcarea (e.g.,C:\Projects\Order Entry\appsrc\config\templates.xml).
These are XML files that contain a list of all the components that can be used. When a workspace is loaded, it reads the contents of the system template definition file and, if present, reads the contents of the workspace template definition file. It combines the two and presents the list of components in the Create New dialog.
Each component in this list is created by either:
- Running a wizard. Those components have a file extension
.exe. - Loading the file based on a template. Those components usually have file extensions
.tpl, although they can be anything other than.exe. - Using special predefined names that the Studio understands. These are used to run special internal processes. Currently, those reserved names are
CLIENTWEBSERVICE,IMPORTACTIVEX,IMPORTAUTOMATION, andIMPORTEMBEDDEDOBJECT.
The contents and actions of a workspace's Create New options can be customized in two ways:
- You can alter the contents of the template definition file (i.e., the list that contains all of the templates).
- You can change the actual contents of any template file.
Altering the Contents of a Single Template File
Template files work in a straightforward manner. When you create a component using a template, the contents of that file are copied into your new file. What you see is what you get. If you want a template file to behave differently, simply change the contents of the template file.
You can change anything you want in a template. You can change the names of classes, add additional use statements, and modify the way a component is defined. Using a template is essentially the same as loading an existing component and saving it under a different name. This is also a perfectly valid way to create new components and may be the technique that most developers will favor.
The Studio currently uses the following template files:
MDIApplication.tpl
WebServerApplication.tpl
BlankApplication.tpl
DataEntryView.tpl
TabbedView.tpl
TableLookup.tpl
ModalDialog.tpl
dbModalDialog.tpl
AboutDialog.tpl
PasswordDialog.tpl
ReportView.tpl
WebBrowserObject.tpl
WebServiceObject.tpl
BusinessProcess.tpl
Asp.tpl
Html.tpl
ClassPackage.tpl
Package.tpl
These are all located in the system config directory (e.g., C:\Program Files\DataFlex\pkg\config). These are factory-installed templates and should never be changed. If you wish to change a template, you must make a copy and place it in your workspace's config directory (e.g., C:\Projects\Order Entry\appsrc\config\) or in a library's config directory. Once it is saved in a directory, you can change it any way you want.
When a template is used, the Studio always first looks in the local workspace config directory for the file. If it finds it, it will use it first. If the template is not found, it will look for the template file in one of your library config directories. If not found in the library config areas, it finally looks in the system config area. If it is not found, an error is reported.
If you wish to alter a template for a specific workspace, you should copy the template into the workspace directory and change it. If you wish to make changes in a template that will be used across workspaces, you should create a library and place the template file in the library. In most cases, the library will also contain the classes needed to support the template.