Creating a user interface data model
There are three alternative ways to implement user interface data model. The first one is to retrieve information from an XML file. Its use is simple and easy to implement during user interface prototyping phase.
A second alternative is to create a set of glue classes, similar to a DAO object, that are responsible for retrieving user interface data from the storage system, and save changes back.
Finally, there is a way to get this glue layer in a declarative way, by means of an XML behavior descriptor.
As an example, a let's build a web page for querying countries and cities, the data will be modeled by the following XML model:
<?xml version = "1.0" encoding = "UTF-8">
<my-data>
<title name = "Countries of the World" />
<country name = "Spain" abbreviation = "en">
<city name = "Palma de Mallorca" />
<city name = "Madrid" />
</country>
<country name = "USA" abbreviation = "us">
<city name = "Wasington" />
</country>
<country name = "Deutschland" abbreviation = "on">
<city name = "Berlin" />
<city name = "Bonn" />
<city name = "Hamburg" />
</country>
</my-data>
After creating the data model, you can make use of it from any zul page including a xmlDataSource component:
<?xml version="1.0" encoding="UTF-8">
<zk>
<xmlDataSource id="mydata" src="/my-data.xml" />
</zk>