Generating code from templates with the web UI framework

You can generate code for select components from templates. Some of those components include mashup APIs, struts actions, and JavaScript Builder.

You can use templates (instead of hand-coding) to generate code for the following components:
  • Mashup APIs
  • Struts actions
  • JSB (JavaScript Builder)
  • Resources
  • Resource permissions
  • Resource and permissions (combines resource and resource permission templates)
  • Menus

The Code Template Generator helps save you development time. For example, you can use a code template to update and test a mashup or JSB file, instead of hard-coding the file and re-starting the application server.

Access the Code Template Generator from the Generate Code button of the Designer Workbench to create code from either default or custom templates. Templates include static (fixed) values, as well as variable values that you can change. Code is generated in a manner similar to the manner in which code is generated for js and config.js files.

After you create the code, you can update the code in a running application without stopping the server. To update the code, you must copy it from the Code Template Generator and paste it in the file of the component that you are updating. The Code Template Generator does not create a new file or add the generated code to a file.

The Code Template Generator is optional, but IBM® recommends that you use it to reduce your development time. You can copy and paste generated code into mashup, Struts, JSB, resource, resource permission, and menu files, instead of hand-coding those files.

The Code Template Generator is not used for extending the application. However, you can use it to test override extensibility changes made using the Designer Workbench.

A new template appears in the Create New Template window, which you access from the Code Template Generator window. If you are creating a new template from an existing template, the Create New Template window includes variables that can be used in the code template and reduce the number of required fields in the Code Template Generator. If you are creating a new blank template, the new template is empty.