6.3.1 The Structure of the Web Code
To implement the Web components , we have to generate code that handles user requests from the Internet and that produces HTML as a response. In general, the complexity of this code can be high. A good MDA tool provides its user with transformations that are highly complex, thus creating a fully functional and working application, using well-established coding patterns. In this book, however, we generate Web code with simple functionality using a simple coding pattern. Although this is clearly not a sufficient MDA solution, we avoid long discussions about complex Web coding solutions.
In this example, the Web part of the application is implemented according to the J2EE standard for Web tiers (Sun Microsystems, Java 2 Platform, Enterprise Edition Specification, Version 1.3, 2001). We generate code that generates simple HTML pages that hold query results only. The components are implemented using JSP (Sun Microsystems, JavaServer Pages Specification, Version 1.2, 2001). Each request from a user instantiates one JSP and the resulting HTML is sent back to the browser. We generate exactly one JSP file for each Web component. At run-time, the JSP produces an HTML page containing a table with rows that correspond to all objects of one type (e.g., all customers) and columns corresponding to the attributes of that type (e.g., address and account number).
The JSPs access the data from the EJB components by iterating over a set of EJB Data Objects and getting the values of the attributes provided by them. The iteration is implemented in embedded Java code. The JSP code uses the EJB data object manager for the retrieval of the data objects. JSP supports the access of get methods for the attributes by simply stating the names of the attributes.
6.3.2 The Transformation Rules
The following rules are used to generate the JSP code from Web Components and the Web Data Classes:
In Appendix B, you can find some fragments of the generated code.