Web Services
  Home arrow Web Services arrow Page 10 - Dynamic Data Analysis on the Web-a Design Approach
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB SERVICES

Dynamic Data Analysis on the Web-a Design Approach
By: developerWorks
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 14
    2004-12-29


    Table of Contents:
  • Dynamic Data Analysis on the Web-a Design Approach
  • Data analysis concepts
  • Dimensions and measures
  • Filtering and ordering
  • Dimension, measure, and slice dimension tags
  • Presenting data
  • Value formatting tags
  • Use of JavaBeans to provide dynamic values
  • Reporting common errors
  • Tag containment
  • Custom tags: lightweight, cheap, replaceable
  • Benefits of this design approach
  • In conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Dynamic Data Analysis on the Web-a Design Approach - Tag containment
    ( Page 10 of 13 )

    To associate the contained tags with some particular purpose or context, it is often useful to provide custom tags that act as containers for other types of custom tag. Examples in Listing 1 include the dimensions tag, the sliceDimensions tag, and the includeFilter tag. All three of these tags can contain dimension tags, and in each case, the contained tags specify the dimensions which are to be applied in a particular way when fetching the data. Listing 6 shows the dimensions tag again for reference.

    Listing 6. The dimensions tag from Listing 1


    <%@ taglib uri="/WEB-INF/tlds/dd.tld" prefix="dd" %>

    <dd:data id="sales">
      <dd:dataSource>Sales Figures</dd:dataSource>

      <dd:dimensions>
        <dd:dimension>Year</dd:dimension>
        <dd:dimension>Product</dd:dimension>
      </dd:dimensions>

      and so forth..

    The dimension tag will implement the JSP BodyTag interface, as it needs to work with the text contents of the tag (which is the dimension name). The most straightforward implementation is to extend the BodyTagSupport class, and override the doEndTag method to extract the body text. However, it is not the dimension tag itself that needs to know the dimension name. It is actually the containing tag (the dimensions tag in this example) that knows what to do with it. So, a system is needed for passing the dimension name to whatever containing tag can handle it.

    The JSP findAncestorWithClass static method is very helpful for locating a suitable containing tag. Notice that this method does not only look at the immediate containing tag (which is known as the parent tag), but continues to look at parent tags all the way out until it either finds one that is suitable or runs out of tags to look at. This is important because the example here has the dimensions tag as an immediate parent of the dimension tags that are within it. Many reasons exist why other tags might come in-between. For example, the page author might use some suitable conditional inclusion tags to selectively activate certain combinations of the contained tags, and the findAncestorWithClass method will step past any such intervening tags and find the required containing tag if it exists.

    Of course, quite a variety of tags might want to contain dimension tags. To enable the dimension tag handler to find the right container, a Java interface is created. Listing 7 shows a suitable interface. Any custom tag that is designed to contain dimension tags needs to implement this interface, as well as the JSP Tag interface. Listing 8 shows a typical implementation of the doEndTag method for the dimension tag itself.

    Listing 7. An interface for containers of dimension tags to implement


    public interface DimensionTagContainer
    {
      /**
       * Supply the name of a dimension from a contained dimension tag.
       * @param dimensionName The name of the contained dimension.
       * @throws JspTagException If this tag cannot accept the contained dimension.
       */
      void addDimensionName(String dimensionName)
      throws JspTagException;
    }

    Listing 8. Implementing the dimension tag handler


    public class DimensionTag extends javax.servlet.jsp.tagext.BodyTagSupport
    {
     /**
      * Give the body content as a dimension name to the containing tag.
      */
     public int doEndTag()
     throws JspException
     {
      final DimensionTagContainer container =
       (DimensionTagContainer)TagSupport.findAncestorWithClass(this, DimensionTagContainer.class);

      container.addDimensionName(getBodyContent().getString());

      return EVAL_PAGE;
     }
    }

    You can use this same strategy repeatedly at each level of containment. The data tag needs to contain several types of custom tags, including the dimensions tag we have been discussing. By implementing a suitable interface, the data tag can ensure that it will be found by the dimensions tag handler, which can then report to it the complete set of dimension names to be fetched. The dimensions tag will be told each of these names by the dimension tags it contains, and it will store these in a suitable list until its own doEndTag method is called.



     
     
    >>> More Web Services Articles          >>> More By developerWorks
     

       

    WEB SERVICES ARTICLES

    - Dynamic Data Analysis on the Web-a Design Ap...
    - Use collection types with SOAP and JAX-RPC
    - Blogging Away To Glory (A bBlog Primer)
    - Introduction to Service Oriented Architectur...
    - Connecting Smart Devices on the Internet
    - An Embeddable Standards Compliant Web Servic...


    Email Marketing Software
    iContact Email Marketing Software Simplifies Online Communication.
    Online Survey Software
    Vovici online survey software, sample surveys & survey templates.
    Internet Marketing Company
    Provider of internet marketing services to boost your site rankings.
    SEO Services
    Top seo services provider; great organic rankings & qualified traffic
    SEO Firm
    SEO firm with excellent organic results for clients in all verticals



    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT