Defining Data in XML Form

The previous chapters described how simple data can be accessed by a renderer and marked up with HTML for presentation. For complex widgets, simple values like that are usually not sufficient. It is often preferable for the value to be an XML document that contains all of the data required for the widget in a structured form. In the case of this photograph widget, the concern role ID of the person and the name of the person are required to present the photograph correctly. As the widget is associated with a UIM FIELD element that can only specify one SOURCE connection to the required data, both the ID and the name must be passed back in a single server interface property. The Cúram application provides support classes that make it simple to access data expressed as an XML document, so an XML document containing the values is the preferred form when combining data into a single server interface property.

Below is a sample of an XML document that represents all of the information required to present the photograph of a person. The id element defines the concern role ID value passed to the FileDownload servlet using the id parameter shown in the example in the previous section. The name element defines the name of the person to be shown below the photograph. To make best use of the support classes provided with the Cúram application, the values should be given in the body of the elements, rather than as attributes of a single element. The XML document is constructed in a server facade and returned in a single (string-based) property.

Figure 1. An XML Document Describing a Photograph
<photo>
  <id>101</id>
  <name>James Smith</name>
</photo>