Uniface Default Templates

Uniface provides a default set of templates and snippets that enable you to create new development objects and components that can work immediately. In fact, it is not possible to create a new object without a template.

The Uniface templates are extensive but not exhaustive. The are used to create new objects but they also serve as examples. They demonstrate the different properties that can be set when you want an object for a specific purpose, and they provide instructions, hints, and suggestions for how triggers and default code can be used or modified. In some cases, you may need to make some changes in properties and code to make the sample work.


The Uniface templates include:

  • At least one template for each type of development object. For many objects, there are multiple templates, which set different properties and code to serve different purposes.

    For example, there are many templates for defining fields. In modeled entities, there are several types of String field; in interactive components, there are field templates for each widget type.

  • Default code to ensure that objects do something out-of-the-box. For example:
    • Database entity templates provide code for the store, retrieve, read, and write triggers to ensure that you can create and retrieve data with zero coding.
    • Component templates have a default exec operation and other triggers to ensure that the component can be activated.
  • Templates for entity control buttons in interactive components (dynamic server pages, static server pages, and forms). These enable you to provide-component specific behavior that enables the user to retrieve, create, and store data.
  • Snippets for all triggers, including the declaration and suggestions for their use. These are provided in snippet libraries for entities (USCRIPT_ENT) and components (USCRIPT_CPT) and provide an overview of the available triggers per object.

    For example, snippets for the all the DSP component, entity, and field triggers are delivered in a snippet library called USCRIPT_DSP.

    Resource Browser in the Write Script worksheet, showing trigger snippets delivered
    in the USCRIPT_DSP snippe library

  • Snippets for common ProcScript constructions, such as for and while loops, conditional selection, newinstance, activate and call invocations, and so on. These are delivered in the USCRIPT_COMMON snippet library.
  • Snippets for HTML constructions that can be used in the layout of dynamic and static server pages.

The Uniface default templates are delivered as a hidden project called UTEMPLATES, which are delivered in the utemplates.xml file, located in the uniface\misc directory of your Uniface installation.

Note:  If you want to explore the contents of these UTEMPLATES, or duplicate and modify it to create your own set of default templates, you first need to set the logical ALLOW_BROWSE_TEMPLATES=1 in the ide.asn file. Define Palettes and Templates

Template Code and Snippets

All code provided in templates and trigger snippets serves as an example that you can modify to suit your own requirements. The provided code may include any or all of the following as comments or optional code:

  • An explanation of what the code does and guidelines for its use.
  • A TO DO section that lists additional, alternative, or optional steps required to make the code work. For example, you may need to define a constant or set a variable to a different value.

    Note:  The TO DO instructions may include some pseudo-code, which cannot be copied and pasted as is.

  • Pre- and post-conditions, such as the condition that occurs before a trigger gets fired and the consequences of certain return values.

    For example, the store and accept triggers only fire when implicit validation of current active path is successful. The return value of some triggers, such as like leaveField, quit, and accept influences the behavior of subsequent triggers.

  • Alternative implementations for the same trigger or functionality, such as a webtrigger onChange (JavaScript) or trigger onChange (ProcScript).
  • Optional code that demonstrates of how some behavior can be coded. This is implemented using an #ifdefined/ #endif block that is executed only when a constant is defined. To enable this in code, removed the #ifdefined condition.

    For example, the read trigger snippet includes options that demonstrate how it can be used to discard hits based on a procedural condition, invoke DBMS functionality such as paging and sorting, and how to handle read errors.

Note: The default Uniface templates are exception-enabled with a throws declaration.

Related Topics