Learn about an adaptable approach which separates programming tasks from Web page design tasks. This strong conceptual model encourages good design, enables re-use of data definitions, and is well-suited to the construction of dynamic user interfaces. The authors also illustrate the particular challenges you might encounter when you dynamically change the analysis performed by Web pages. (This intermediate-level article was first published by IBM developerWorks, August 5, 2004, at http://www.ibm.com/developerWorks).
The design approach described in this article uses a set of custom JSP tags to implement an OLAP-like data model, which provides an architected interface between the data access and presentation parts of a Web application. The sections that follow describe the benefits.
Separation of data access from presentation
It is widely recognised that an architectural separation between data model and presentation is desirable within all but trivial Web applications. For instance, the Model-View-Controller paradigm is one widely used approach to achieve this, and the architecture described in this article is compatible with such approaches.
As well as providing a well-defined interface to separate the implementation of data access from that of presentation, the actual tasks of creating such implementations are also separated. Once the initial work of defining the data sources (in terms of dimensions, measures, and so forth) is complete, then the tasks of implementing them and any pages that depend on them can be done in parallel and by different individuals.
Separation of the roles of page author and data access programmer The OLAP-like data model is inherently simple, but retains a high degree of flexibility. It neatly surfaces the key concepts most commonly required to control the analysis and delivery of data for presentation, while insulating the page author from almost all of the details of how it is achieved. When combined with the separation of data access from presentation, this means that not only can the tasks of page authoring and data access programming be done by different people, but that those people do not need to have the same skills. Indeed, specialists can now be employed to undertake each task, with their efforts focused towards providing and using the data sources that are the central feature of the data model.
The OLAP-like data model, in conjunction with a well-implemented data source, provides the page author with little likelihood of inadvertently configuring an incorrect analysis of the data. This is in stark contrast to technologies such as SQL, where a simple typographical error or misunderstanding of the database schema can lead to very significant and sometimes subtle errors.
From the perspective of the data access programmer, the OLAP-like data model provides a lot of flexibility for implementation. It is conceptually simple and requires only the ability to filter and aggregate data to support it. This leaves a considerable design space for the data access programmer to exploit any capabilities of the underlying data source (such as converting requests into appropriate queries against a relational database, for instance).
The illustrated tag library is particularly suited to dynamic configuration as a result of form submission. The individual component tags that are used to configure a data tag, such as filter tags and ordering tags, can be readily integrated with conditional logic tags and input from form fields. This enables the page author to create pages that permit the user to control some parameters of an analysis (such as selecting a sales region to filter the results to, or selecting whether to aggregate by months or quarters, and so forth).
Reusable data sources
A well-thought-out data source can be used to supply data for a variety of pages. It is not necessary to use every dimension and measure whenever a data source is used -- just the subset required for the particular purpose. So, data sources can often be defined that offer a common superset of the dimensions and measures needed for several different analyses/pages.
Encourages good design
The fact that the design approach is centered around the definition of the required data means that this critical aspect of the design must be approached early on and in considerable detail. Neither the implementation of the pages nor the data sources can begin before the definition of the data source in terms of dimensions and measures is done. Furthermore, considering the data to be used in the relatively abstract terms of dimensions and measures encourages good conceptual design independent of the physical details of how the data will be displayed or accessed. In short, this approach encourages design before implementation, as well as conceptual design before physical design.
These data definition and data presentation tag libraries conform to the J2EE 1.2 standard, making them compatible with a wide range of Web application servers.
The custom JSP tags that are used to implement the interface between page author and programmer are readily understood by integrated development environments and other tooling, thus improving productivity.