Code template generator of the web UI framework

Access the Code Template Generator from the Generate Code option in the top toolbar of the Designer Workbench.

The generator includes the following sections:

  • Available Templates

    Displays all of the available templates in a tree view. Includes default and custom templates. Default templates are available for JSB (JavaScript Builder), mashups, Struts actions, resources, resource permissions, and menus.

    The applications that only consume the uifwk clump would only have the default JSB template available in the existing Designer Workbench.

    Create custom templates from copies of the default templates.

  • Template Details

    Includes variable text that you can change (the Template Input Variables section) and the code that is generated from the template (the Generated Code section). The fields in the Template Input Variables section depend on the type of template.

Code Template Generator window

For example, you could create a new JSB template from the default template by right clicking on default JSB Template and then clicking on Create from selected. This brings up the Create New Template window. Then, you would use the User Defined Variables section of the Create New Template window to add a new target_name variable that uses the type expr and the value className. If you use the same code template, then you can remove the Target Name input as this variable would now get the value of the className variable. Once saved, this custom JSB template would have five input fields on the Code Template Generator window instead of the six input fields that appear on the default JSB template. You could also modify the template and use the className variable instead of the target_name variable, with the same result.

You cannot change a default template, but you can copy its contents to make a custom template. You can edit a custom template or copy its contents to make another custom template.

The fields that appear in the Template Input Variables section depend on the component that you are changing. The values that you enter in this section are assigned to the XML code that will be generated. These values are also stored in the json file of the screen.

For example, in the above graphic showing a JSB template, stk is the value of the Project Name variable, which is the label for the proj_name variable (JSB project) used in the code template. The stk value would be assigned to its corresponding variable (proj_name) and replaced in the generated code.

The values in the Template Input Variables section appear in the Generated Code section after you click the Generate Code button. You can directly change the generated code, but these changes will be lost if you click the Generate Code button again during this session. The text in the Generated Code field is not saved to a file on disk. You can copy the generated code to another file.

Clicking the OK button saves all of the screen's changes to the screen's json file and closes the Code Template Generator. That is, all of the variable values for all of the templates are saved. Clicking the Cancel button closes the Code Template Generator without saving changes to the screen's json file.