SOAP & Web Services Page 9 - Dynamic Data Analysis on the Web-a Design Approach |
When filtering is applied to data, it is not uncommon to find that no rows of data match the filtering criteria. The page author might wish to deal with this and other exceptional occurrences gracefully. An ifDataState tag can be used to allow various common conditions to be anticipated, detected, and reported in a structured way. Listing 5 illustrates the use of ifDataState tags in a common pattern used to protect against empty result sets and access violations.
The example in Listing 5 assumes that identification, authentication, and authorization mechanisms are in place to match the user with access rights for the associated data. The details of such a scheme are beyond the scope of this article. What is important is that the problem has been encapsulated by the custom tag, and that the page author does not have to worry about the nasty details. In this example, two cardinalities of result rows are then tested. Each cardinality test can only be satisfied if the authorisation test is met and data is successfully fetched. The first cardinality test recognises the empty result set situation. The next performs the data presentation if at least one result row is available. Other cardinalities might be tested for, but these are the most common. Implementation notes The JSP specification provides services which enable cooperating sets of custom JSP tags, such as those described here, to be developed and deployed successfully. This article is not intended to be a detailed survey of JSP custom tag development, but this section does address some of the principle issues in the implementation of sets of custom JSP tags of the type we have discussed here. It also provides pointers to appropriate parts of the API and the associated documentation.
blog comments powered by Disqus |