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).
When focusing on a subset of data, such as one particular sales region, filtering is required. You might achieve filtering by specifying data to be included or less commonly, data to be excluded. You need to identify the dimensions to be tested for the values.
It is often useful to present data in a certain sequence so the ability to specify the order in which slices and rows within each slice are returned is required. Alphabetic ordering uses the lexicographic sequence of values, while numeric ordering works by numeric comparison. Other custom orderings are also possible. Ordering might be in ascending or descending sequence.
The conceptual model for data
To enable the page author to express data requirements in the terms described above, a set of custom JSP tags can be provided. The programmer will need to implement a tag handler for each of the custom tags and create a tag library descriptor file, which defines the custom tags and associates each custom tag with its tag handler. When you contruct a Web page, you can embed the custom JSP tags, and identify the appropriate tag library descriptor along with a prefix used to distinguish this set of custom tags.
A well designed custom tag library closely reflects the conceptual model to the page author. Listing 1 shows a set of custom tags that present the OLAP-like data model described above. In this example, a data source is identified along with the dimensions and measures which are required for a particular analysis, and the slice dimensions, filters, and orderings which are to be applied.
Listing 1. A representative set of data definition tags
In Listing 1, the taglib directive establishes the scope of the data definition tags within the JSP with a prefix here of dd.
The data tag acts as a container for all the other data definition tags, which together define the required data and how the results are to be arranged. The id attribute provides a means of referencing the results, and we shall see how this is used in the Data presentation tags section.
The dataSource tag identifies the name of the data source of interest. The data source must contain all of the dimensions and measures referenced within this data tag.