IBM Version 5 manual

Models: Version 5

1 340
Download 340 pages 15.44 Kb
Page 244
Image 244

Figure 10-12 Registration project structure after the Web tier creation

Java source files: By expanding the Java Source folder, under the CustomerInfoWeb project, you will find two new Java files, in addition to our original customer bean Java file. The first new file is CutomerXML.java, which is responsible for converting a JavaBean into a DOM representation. The second new file is CustomerXSLServlet.java, which is the controller of the whole process as it is responsible for invoking the required business logic, and applying the XSL to the generated DOM.

Following is a brief explanation of the contents of these two Java classes:

￿CustomerXML is responsible for converting a JavaBean into a DOM representation. Studying the code for this class, we notice the following:

It has an attribute referencing our customer JavaBean. This attribute represents the bean to be transformed to the DOM representation.

It has a set of get and set methods to handle the values of the Customer bean attributes. For example, the setMembership method of the CustomerXML, sets the value for the membership attribute of the Customer bean. This applies to all customer bean attributes. These are useful of storing and retrieving the bean data values.

The method responsible for the transformation is produceDOMDocument. As shown in Figure 10-13, given the JavaBean as an input to the produceDomdocument method, the method uses Sun's jaxp (Java API for XML processing) to produce the XML data from the JavaBean. The source code for that method is available in Example 10-1. It creates a

228 The XML Files: Development of XML/XSL Applications Using WebSphere Studio

Page 244
Image 244
IBM Version 5 manual