TOC PREV NEXT INDEX



Using an Output Template


Although the XML output format is useful for custom clients and mobile devices, it is not a very satisfactory output format when used with a browser. One of the best ways to turn this data into a more presentable format is to use a Templating engine. In this demonstration we will use a module that uses the WebMacro Templating engine to generate nicely formatted web pages. To accomplish this goal follow these steps:

  1. Discard the XMLExport Module by dragging it to the Recycling Bin node in the Enterprise Composer.
  2. Drag the "WebMacro Template" icon from the "Template" tab of the Simplicity Enterprise Module Palette to the Modules portion of the Enterprise Composer tree. Drop it just after the ResultTable node.
  3. Select the Properties node of the WebMacro node.
  4. In the list of the property sheet to the right, select sQLStatement, resultTable_tableData and resultTable_columnNames.
  5. In the text field above the list type in "JDBCDemo.wmt" (without the quotes).

To test that this worked, go back to the web browser, select the back button to get back to the Catalog Search Form, and re-submit the form. You should get a nicely formatted web page with a table of the results and a servlet diagnostics section following the primary results. As before, changing the data you type into the form changes the results you get.

Congratulations, you have completed your catalog search servlet!

Some explanation is required here. Basically, what happened was that the WebMacro module reads in a previously prepared HTML template called JDBCDemo.wmt and inserts the data that you selected in the list into the template.

The template is a standard HTML web page, with one minor difference: it has WebMacro script added to it to determine where the data goes. This template was created by a web designer using standard web design techniques to control such features as fonts, colors, images and table formatting. All of these things are strictly presentation issues and have nothing to do with actually generating the data. By isolating these sorts of things to the template, we separate presentation issues from programming issues, or business logic. This allows, you, the programmer and your web designer to work independently on what you do best, it also reduces the complexity of the jobs each of you have to do and has numerous other advantages. See the Templating Engine section of the manual for more details on how to create and use templates.


Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX