tags. You can make several different versions of the TableWrapper tag, with different qualifiers, but they all should be crafted to fit within all versions of the DisplayPageWrapper and the DataEntryPageWrapper constructs.
HTMLWRAPPER tags
The HTML templates provided by IBM® WebSphere® Portlet Factory include tags around some of the markup.
This is part of the XML markup of the model. The tag is used to contain elements of the page to which you can apply other builders. This tag is used in place of standard HTML tags in places where HTML markup would not allow a tag, for example, between a
and a tag. When the page is transformed to JSP, these tags are removed, leaving valid HTML markup.
The following is an example of how this tag is used around a table row in the columnar.html template.
<HTMLWRAPPER name="LabelContainer">
<TR name="TableLabel">
<TD colspan="4">
<SPAN name="LabelText">Table Label</SPAN>
</TD>
</TR>
</HTMLWRAPPER>
For custom HTML, you can use this tag around elements that you intend to attach with builders. Be sure to provide a unique name on the name attribute.
Qualifying a construct by field control type
You can also qualify the DataEntryField and the DisplayField according to the control type that will be used to display them, using the qualifier _ (including the underscore).
For example, if your normal data entry field layout is to have 4 columns containing the label, the required prompt, the input element, and the validation error, respectively, but when the input element is a text area, you would like, instead, to use two rows, where the first row has the label, the required prompt, and the validation error, and then the second row contains a single column (with colspan=4) which holds the textarea element. In this case, you would specify the normal DataEntryField construct with the name "DataEntryField," and then create another construct named DataEntryField_textarea.
Qualifying a construct by container/field name
To create a construct for a specifically named node that you know is going to appear in your data, use the qualifier.
This always gets the highest precedence. For example, if you know that your data contains a repeated element named "Order" and you want to use a non-default table layout for that table, you can create a construct named TableByName_Order which will be used only for the container named "Order".
Qualifying a construct by container/field type
In some cases, you might want to change the display of certain elements based on the type of the element.
For example, you might normally have column heads and column data left-aligned. However, if the data type is double you would like to center-align the column head and right-align the data. You do this by creating a construct name with the qualifier _. For the example above, you would have the normal ColumnHeader and ColumnData constructs, then you would add two other additional complete constructs with the names ColumnHeader_double and ColumnData_double.
Note: There is a special type name, "autodelete," that is applied to automatically generated columns created in the Data Column Modifier and which provide the delete functionality. This type is applied to all delete columns, no matter what type of delete column choice was selected (Link, Button or Checkbox). You can use the autodelete type qualifier with ColumnHeader or ColumnData constructs: for example, ColumnHeader_autodelete.
How Themes and HTML templates can work together
The default theme for a project provides a convenient way for you to specify HTML template files in your application.
HTML template files describe the formatting for all constructs generated by builders in the application. Using a theme, you can control HTML template use at the project level and in individual models. An input (Use Theme) in the following builders lets you invoke HTML template files based on the project default theme.
- Data Page
- Input Form
- View & Form
These builders are used to generate the user interface (UI) in your application. Using the project default theme lets you manage HTML template use for your application UI in a central location. For an individual model, you can override the project default theme by using the Theme builder to specify different HTML templates files that override the defaults.
If you do not use a theme in those builders, use inputs (HTML Template File) to specify HTML template files for different page types. These specifications of HTML templates can be overridden by other builders at any level in the page automation hierarchy of contents, such as a Data Field Modifier or a Data Column Modifier. There is a hierarchy of action associated with the formats: more specific references override more general (global) settings. Thus a Data Field Modifier specification for a Field or Container node overrides the corresponding specification for that construct in the HTML template file.
When a template file is specified for a container, it is also used for all elements within that container, unless it is further overridden at a lower level.
You can also override a template file with the Data Hierarchy Modifier builder. In this case, the override does not affect the containers that were selected. Only new group containers that the builder creates are affected. This is a common reason to use the Data Hierarchy Modifier: so that you can quickly create new groups with an entirely different display style.
Page automation example: adding spacer rows to a table
By changing only the template, you can add spacer rows anywhere in a table: before the header, between the header and the data, before or after each data row, and after the entire table.
This example has far too many spacer rows. Notice that it uses a Construct Name Qualifier of ByName_PhoneNumber so that this construct will only apply to a container with the name PhoneNumber.
The important step for adding spacer rows before and after the data rows was to separate the RepeatElement from the DataContainer. In the basic template, the DataContainer element of the table construct was not specified, so it defaulted to the same XML node as the RepeatElement. In this example, we want to repeat more than just the data row, we want to repeat around a section that includes the data row and the spacer rows. This is accomplished by adding a tag which acts as the repeat element, and adding the
for the DataContainer within it.
Note: All of the containers are left empty. This is because this overrides only the table construct, and the system will continue to use the ColumnHeader and ColumnData constructs that are already defined in the template. The (rather hideous) result of this addition to the basic template is beside it.
<table name="TableByName_PhoneNumber">
<tr><td colspan="100">
--- spacer row above header ---
</td></tr>
<tr name="TableHeaderContainer"></tr>
<tr><td colspan="100">
--- spacer row below header ---
</td></tr>
<span name="RepeatElement">
<tr><td colspan="100">
--- spacer row above each data row ---
</td></tr>
<tr name="DataContainer"></tr>
<tr><td colspan="100">
--- spacer row below each data row ---
</td></tr>
</span> <!-- end Table.RepeatElement -->
<tr><td colspan="100">
--- spacer row below entire table ---
</td></tr>
</table> <!-- end Table construct -->
Page automation example: changing page layout based on control type
Often you will want to change the layout for a field based on the control type. The most common situation is that you want any field which is edited using a textarea get the entire width of the screen for the textarea, even though the other fields are using only the right-hand portion for their edit devices.
With the following change to the basic template, plus a Data Field Modifier builder on the Comments section which tells it to use a textarea for editing, we get the desired results. For comparison, the normal Data Entry Field construct is shown here along with the qualified one.
<tr name="DataEntryField">
<td class="label"><span name="FieldLabel">Sample Field Label</span></td>
<td><span name="FieldRequired">*</span></td>
<td><span name="FieldElement">Sample Field Element</span></td>
<td><span name="FieldValidationError">Sample Validation Error</span></td>
</tr>
<span name="DataEntryField_textarea">
<tr>
<td class="label"><span name="FieldLabel">Sample Field Label</span></td>
<td><span name="FieldRequired">*</span></td>
<td></td> <!-- Leave empty so Validation column lines up. -->
<td><span name="FieldValidationError">Sample Validation Error</span></td>
</tr>
<tr><td colspan="4">
<textarea name="FieldElement" cols="40" rows="10"></textarea>
</td></tr>
</span>