Dynamator Pure HTML for every page generation technology.
           

Dictionary Lists

This example shows how to output the elements of a dictionary or properties object as a dictionary list. Dictionary lists are different from the previously covered repeated HTML elements because for each element of a collection, two HTML elements are repeated.

Page

This example is a page that shows the current system properties values:

HTML

To repeat dictionary entries for each element of an indexed property, add a 'class' attribute to the 'dl' element. Note that this is different from the table example, in which the 'class' attribute was added to the repeating element. This is because 'dl' has two repeating elements.

It might seem like a good idea to put a 'div' element around a 'dt/dd' element pair, but that's not valid HTML.

The 'dt' and 'dd' elements must also be given a 'class' attribute.

SystemProperties.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>System Properties</title>
</head>
<body>
<dl class="Properties">
  <dt class="PropertyName">property name one</dt>
  <dd class="PropertyValue">property value one</dd>
  <dt class="Discard">property name two</dt>
  <dd class="Discard">property value two</dd>
</dl>
</body>
</html>

Dynamator File

When iterating over a dictionary list, the 'foreach' attribute must be applied to the 'dl' element. If applied to the 'dt' and 'dd' elements, all the 'dt' elements would be together, followed by all the 'dd' elements.

SystemProperties.dyn
<dynamator language="jsp">
  <prolog>
    <%@ page session="false" %>
  </prolog>
  <class name="Properties">
    <foreach type="Properties" element="property">
        System.getProperties()
    </foreach>
  </class>
  <class name="PropertyName">
    <content>propertyName</content>
  </class>
  <class name="PropertyValue">
    <content>property</content>
  </class>
</dynamator>

For Properties and Dictionary objects, the 'element' variable refers to the value part of an entry. For a Properties object, the name of the variable referring to the key part of an entry is the element variable name followed by "Name". For a Dictionary object, the name of the variable referring to the key part of an entry is the element variable name followed by "Key".

JSP file

After processing with Dynamator, the resulting JSP file looks like this:

SystemProperties.jsp (generated by Dynamator)

In Action

If you are viewing this page in a servlet engine, you can see the generated page in action.