|
A UDM
(User-level Data Model or User Data Model) is a
collection of data items that “belong together” in
some sense – typically in the sense that they will
be retrieved (or stored) in response to a single web
request. In other words, the UDM is a “map” of
retrieved or stored data in the manner in which it
will appear on screen. Each UDM’s elements are
organized as a tree, so that it is easier to
comprehend. For example, suppose you wanted to create
a simple web page that displays a person’s
attributes, all of which come from a database table.
You might then specify the data elements you will show
in a “UDM tree” that looks like this:
|
|
|
The
indented structure is meant to represent a tree whose
root is named personUdm, and the root has a single
child named person. The children of this child are the
actual data elements to be shown in the web page. Not
coincidentally, the names of these elements are the
same as those of the columns of the table from which
the data is read.
With
the zeroCode engine, you can retrieve (or store) all
the data specified in a UDM in a single request.
Suppose, then, that you created a web page that
invoked the zeroCode engine to retrieve the above
UDM’s data. That page could use access UDM’s data
elements in an HTML template like this:
<html>
<body>
${personUdm.person.firstName}
${personUdm.person.lastName}<br>
Born ${personUdm.person.dateOfBirth}
</body>
</html>
The
${ and } symbols are used to demarcate a reference to
the UDM’s data element. Such a reference is called a
template variable.[1] The data element is named using
the sequence of names from the tree’s root to the
element, separated by periods. In this example, after
zeroCode replaces the template variables with
corresponding values, the output HTML might look like
this:
<html>
<body>
John Doe<br>
Born 4/10/1964
</body>
</html>
_____________________________________________________________________
This
syntax depends, of course, on the template engine.
The one used by zeroCode, requiring the above
syntax, is FreeMarker, an open-source Java template
engine. See http://freemarker.sourceforge.net
for documentation.
|
|