Managing templates

From the pop-up menu for the default XHTML export template (with no items selected), you can create multiple templates and save them by name with the DataWindow object open in the painter. You also can edit existing templates associated with the current DataWindow object and, when you associate more than one template with the DataWindow, delete the current template:

The pop-up menu has these options for managing templates:

Menu item

Description

New Default

Define a new default XHTML export template based on the current DataWindow layout

Open

Open a saved template

Save

Save the current template; if the template has no name, name it

Save As

Save the current template with a new name

Delete

Delete the current template (enabled only if more than one template exists for the current DataWindow object)


Creating and saving templates

Creating a new default template

To create a new default XHTML export template, select New Default from the pop-up menu in the Export Template view for XHTML.

A new default XHTML export template has the following elements:

Elements

Name defaults to

Root <form>

DataWindow name_dataForm

Header <div>

DataWindow name_band1

Detail <div>

DataWindow name_bandn

Summary <div>

DataWindow name_bandn

Footer <div>

DataWindow name_bandn

Child elements of the Header, Detail, Summary, and Footer elements

Name of each DataWindow control.


Saving the template

To save a new default template, select Save from the pop-up menu in the Export Template view for XHTML, name the template, and provide a comment that identifies its use.

The template is stored inside the DataWindow object in the PBL. After saving a template with a DataWindow object, you can see its definition in the Source editor for the DataWindow object. For example, this is part of the source for a DataWindow that has two templates. The templates have required elements only:

export.xhtml(usetemplate = "t_phone"
template = (name = "t_address"
        comment = "Employee Address Book" xhtml = "<...>")
template = (name = "t_phone"
        comment = "Employee Phone Book" xhtml = "<...>") )

Note

Defining multiple templates You can define multiple templates for a single DataWindow object. One reason you might do this is to vary the edit styles generated for the same DataWindow edit control.

Selecting the template to use

Using the Export.XHTML.UseTemplate property

The Data Export page in the Properties view lets you set properties for exporting data in XHTML. The names of all templates that you create and save for the current DataWindow object display in the Use Template drop-down list.

In addition to the properties that you can set on this page, you can use the Export.XHTML.TemplateCount and Export.XHTML.Template[ ].Name properties to let the user of an application select an export template at runtime. See "Selecting XHTML export templates at runtime".

You can specify the template you want to apply to the default XML Web DataWindow or XHTML Web DataWindow generation at runtime by setting the Export.XHTML.UseTemplate property. You set the property using the Data Export tab in the DataWindow painter's Properties view by selecting XHTML as the format and then selecting the XHTML export template's name from the Use Template drop-down list box.

You can also set the Export.XHTML.UseTemplate DataWindow property in script. For information, see "Selecting XHTML export templates at runtime".

Incorrect setting of the UseTemplate property

If you set the Export.XHTML.UseTemplate property at runtime to the name of a template that does not exist, the built-in default Template is used on an export.

Properties related to XHTML export templates

The following table shows properties related to XHTML export templates.

Property

User interface fields

Description

Export.XHTML.TemplateCount

Read only, so no user interface field.

The number of XHTML export templates associated with a DataWindow object

Export.XHTML.Template[num].Name

Read only, so no user interface field.

The name of an XHTML export template associated with a DataWindow object returned by index value that ranges from 1 to the value of the Export.XHTML.TemplateCount property

Export.XHTML.UseTemplate

Select a template from the Use Template drop–down list box in the Data Export tab in the DataWindow painter's Properties view.

The name of an XHTML export template (previously saved in the DataWindow painter) that optionally controls the logical structure of the XHTML generated by a DataWindow object


For detailed information about DataWindow properties, see DataWindow Reference.