com.sas.servlet.beans.mdtable.html
Class MDTable

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.mdtable.BaseMDTable
                    |
                    +--com.sas.servlet.beans.mdtable.html.MDTable

public class MDTable
extends BaseMDTable

Transformation bean for creating HTML tables that represent data stored in a Mulitdimensional Database. See the documentation for com.sas.sasserver.mdtable.MultidimensionalV2Interface for additional information.

The MDTable bean uses cascading styles sheets to control many aspects of the HTML table's appearence. For specific information regarding what styles are used and how they effect the tables appearence, see Styles used by the MDTable Bean.

The following example illustrates the use of the MDTable Transformation Bean. Any model that implements com.sas.sasserver.mdtable.MultidimensionalV2Interface can be used with the MDTable Transformation Bean. Once the model is created the MDTable Transformation Bean can be used to represent the table (the HTML-specific MDTable Transformation Bean will be used).

Example: Use the SASHELP.PRDMDDB multidimensional database as the model and the MDTable Tranformation bean to create an HTML table that displays the multidimensional data.

JSP Page:

 <html>
 <head>
 <title>MDDB Table Bean</title>
 <p>
 <!-- The MDTable Transformation bean uses styles defined in a .css file to control table appearence -->
 <!-- A default style sheet file will be provided. -->
 <p>
 <LINK REL=STYLESHEET HREF="http://d2159.us.sas.com/jsp/mddb_bean1.css" TYPE="text/css">
 </head>
 <body>
 <!-- import needed classes -->
 <%@page import="com.sas.sasserver.mdtable.MultidimensionalTableV2Interface"%>
 <%@page import="com.sas.servlet.beans.mdtable.html.MDTable"%>
 <%@page import="com.sas.servlet.util.Util"%>
 <%@page import="com.sas.rmi.Connection"%>
 <%@page import="com.sas.rmi.Rocf"%>
 <%@page import="com.sas.table.TableException"%>
 <!-- Create the needed MDTable Transformation Bean -->
 <jsp:useBean id="prdmddbObj" class="com.sas.servlet.beans.mdtable.html.MDTable" scope="session">
    <jsp:setProperty name="prdmddbObj" property="borderWidth" value="1" />
    <jsp:setProperty name="prdmddbObj" property="formAction" value="/jsp/mddb.jsp" />
    <jsp:setProperty name="prdmddbObj" property="formMethod" value="GET" />
    <jsp:setProperty name="prdmddbObj" property="cellSpacing" value="0" />    
    <jsp:setProperty name="prdmddbObj" property="maxColumns" value="8" />        
    <jsp:setProperty name="prdmddbObj" property="maxRows" value="10"/>        
 </jsp:useBean>
 <!-- Create a Connection Bean -->
 <jsp:useBean id="connection" class="com.sas.rmi.Connection" scope="session" />   
 <!-- Create a Rocf Bean --> 
 <jsp:useBean id="rocf" class="com.sas.rmi.Rocf" scope="session" />   
 <%
     
   //If you are not using the middleware server you need to make sure
   //the SAS session is terminated when the HttpSession becomes
   //invalid.  Create an Object that implements HttpSessionBindingListener.
   //When the object is unbound the valueUnbound method will run and in 
   //this case call the connection objects stop method which will end
   //this users SAS session.
   
     class SessionMonitor implements HttpSessionBindingListener
     {
        public void valueBound(HttpSessionBindingEvent e)
        {
           //System.out.println("Session is bound. "+e.getSession().getId());
        }
      
        public void valueUnbound(HttpSessionBindingEvent e)
        {
           //System.out.println("Stopping SAS Session");
           HttpSession mysession = e.getSession();
           Connection con = (Connection)mysession.getValue("connection");
           if (con != null)
              con.stop();
        }
     }
   
     //Try to get the sessionMonitor object 
   
     Object sm = session.getValue("sessionMonitor");
   
     //If it is null, create a SessionMonitor object and add it to the session object.
   
     if (sm==null)
     {
        SessionMonitor monitor = new SessionMonitor();
        session.putValue("sessionMonitor",monitor);
     } 

     //Set the appropriate values on the reponse HTTP header so the page will not be cached
     
     response.setHeader("Cache-Control","no-cache");    
     response.setHeader("Pragma","no-cache");
     response.setDateHeader("Expires",0); 
           
     MultidimensionalTableV2Interface mi=null;
     boolean newMDDBModel=false;
     String cmd = null;
     
    //Get the model from the MDTable Bean
     
    mi = (MultidimensionalTableV2Interface)prdmddbObj.getModelInterface();
         
     //If the model is null create a model
             
     if (mi==null)
     {
            
       mi =(MultidimensionalTableV2Interface)
             Util.newInstance(rocf, connection, 
             com.sas.sasserver.mdtable.MultidimensionalTableV2Interface.class);
 	 
 	    if (mi != null)
 	    {
 	       // Set the model
 	    
           prdmddbObj.setModelInterface(mi);   
        
 	       newMDDBModel=true;
 	    }
 	    
 	    	   
 	 }         
 	 
 	 //This page will get called anytime you want to drilldown, go up, or scroll.
 	 //In each case a command name is set when a form is submitted.  The command
 	 //name is used to look up the necessary information on the server to execute 
 	 //the command.  When the page is called using a URL with no parameters cmd
 	 //will be null.  When cmd is null we initalize the MDDB.
 	 
 	 cmd = request.getParameter("CMDNAME");
 	 	 
 	 if (cmd == null || cmd.length()==0)
 	 {
 	 
 	    String col[] = {"Geographic"};
        String row[] = {"Time",};
        String measure[] = {"ACTUAL"};
        String stat[] = {"SUM"};
        String slicers[] = null;
        String axes[][] = { col, row };
 	           
 	    try{  
 	       
 	       // Only do this the very first time.  
 	       if (newMDDBModel)
 	       {
 	          prdmddbObj.initialize(); 
              mi.setMetabase("SASHELP.MBEIS");
              mi.setDatabase("SASHELP.PRDMDDB");
           
              mi.setColumnAxis(col);
              mi.setRowAxis(row);
              mi.setSelectedMeasures(measure);
              mi.setSelectedStatistics(stat);
              mi.initializeTable(axes, slicers, measure, stat);
           
           }
           else    
           {
              prdmddbObj.initialize(); 
              mi.initializeTable();
              mi.initializeTable(axes, slicers, measure, stat);
           
           }
    
        }
        catch(TableException te)
        {
           System.out.println(te.getMessage());
        }
     }
     else if (mi != null)
     {
        prdmddbObj.executeCommand(cmd);
     }
     
     
     // Output the table
     try
     {
        prdmddbObj.write(out);
     }
     catch(java.io.IOException ioe)
     {
        out.println("<H2> Unable to Access Multidimensional Data on the Server. Please contact your administrator.</H2>");
        System.out.println("ERROR: Unable to create Multidimensional Data object on server");
     }
     
 %>
 </body>
 </html>
 

HTML output:

 <html>
 <head>
 <title>MDDB Table Bean</title>
 <LINK REL=STYLESHEET HREF="http://d2159.us.sas.com/jsp/mddb_bean1.css" TYPE="text/css">
 </head>
 
 <body>

 <CENTER><TABLE CLASS="maintab"  BORDER="1" CELLSPACING="0" CELLPADDING="0">
 <TR>
 <TH CLASS="collab" COLSPAN=1  ROWSPAN=1 >Country</TH>
 <TH CLASS="collab" COLSPAN=2  ROWSPAN=1 ><A HREF=javascript:executeCmd("A1"); >CANADA</A></TH>
 <TH CLASS="collab" COLSPAN=2  ROWSPAN=1 ><A HREF=javascript:executeCmd("A2"); >GERMANY</A></TH>
 <TH CLASS="collab" COLSPAN=2  ROWSPAN=1 ><A HREF=javascript:executeCmd("A3"); >U.S.A.</A></TH>
 </TR>
 <TR>
 <TH CLASS="empty" COLSPAN=1  ROWSPAN=1 > </TH>
 <TH CLASS="analycol" COLSPAN=1  ROWSPAN=1 >Actual Sales</TH>
 <TH CLASS="analycol" COLSPAN=1  ROWSPAN=1 >Predicted Sales</TH>
 <TH CLASS="analycol" COLSPAN=1  ROWSPAN=1 >Actual Sales</TH>
 <TH CLASS="analycol" COLSPAN=1  ROWSPAN=1 >Predicted Sales</TH>
 <TH CLASS="analycol" COLSPAN=1  ROWSPAN=1 >Actual Sales</TH>
 <TH CLASS="analycol" COLSPAN=1  ROWSPAN=1 >Predicted Sales</TH>
 </TR>
 <TR>
 <TH CLASS="collab" COLSPAN=1  ROWSPAN=1 >Year</TH>
 <TH CLASS="statscol" COLSPAN=1  ROWSPAN=1 >Sum</TH>
 <TH CLASS="statscol" COLSPAN=1  ROWSPAN=1 >Sum</TH>
 <TH CLASS="statscol" COLSPAN=1  ROWSPAN=1 >Sum</TH>
 <TH CLASS="statscol" COLSPAN=1  ROWSPAN=1 >Sum</TH>
 <TH CLASS="statscol" COLSPAN=1  ROWSPAN=1 >Sum</TH>
 <TH CLASS="statscol" COLSPAN=1  ROWSPAN=1 >Sum</TH>
 </TR>
 <TR>
  <TH NOWRAP CLASS="rowlab" COLSPAN=1  ROWSPAN=1 ><A HREF=javascript:executeCmd("A4"); >1993</A></TH>
  <TD NOWRAP CLASS="tdcell">$121,020.00</TD>
  <TD NOWRAP CLASS="tdcell">$119,329.00</TD>
  <TD NOWRAP CLASS="tdcell">$127,404.00</TD>
  <TD NOWRAP CLASS="tdcell">$117,119.00</TD>
  <TD NOWRAP CLASS="tdcell">$121,053.00</TD>
  <TD NOWRAP CLASS="tdcell">$123,763.00</TD>
  </TR>
  <TR>
  <TH NOWRAP CLASS="rowlab" COLSPAN=1  ROWSPAN=1 ><A HREF=javascript:executeCmd("A5"); >1994</A></TH>
  <TD NOWRAP CLASS="tdcell">$125,970.00</TD>
  <TD NOWRAP CLASS="tdcell">$113,690.00</TD>
  <TD NOWRAP CLASS="tdcell">$118,594.00</TD>
  <TD NOWRAP CLASS="tdcell">$114,435.00</TD>
  <TD NOWRAP CLASS="tdcell">$116,296.00</TD>
  <TD NOWRAP CLASS="tdcell">$117,959.00</TD>
  </TR>
  </TABLE></CENTER>
  <SCRIPT>
  function executeCmd(command,dateTime)
  {
  document.MDDBFORM.CMDNAME.value=command;
  document.MDDBFORM.submit();
  }
  </SCRIPT>
  <FORM NAME="MDDBFORM" METHOD="GET" ACTION="/jsp/mddb2.jsp">
  <INPUT TYPE="HIDDEN" NAME="CMDNAME" VALUE="" >
  </FORM>
  
  </body>
  </html>
  

Browser Table:

Country CANADA GERMANY U.S.A.
  Actual Sales Predicted Sales Actual Sales Predicted Sales Actual Sales Predicted Sales
Year Sum Sum Sum Sum Sum Sum
1993 $121,020.00 $119,329.00 $127,404.00 $117,119.00 $121,053.00 $123,763.00
1994 $125,970.00 $113,690.00 $118,594.00 $114,435.00 $116,296.00 $117,959.00

See Also:
BaseMDTable, MultidimensionalTableV2Interface, Serialized Form

Fields inherited from class com.sas.servlet.beans.mdtable.BaseMDTable
columnAxis, columnCount, columnLabels, columnLevels, columnUpAxisLabels, endColumn, endRow, executedCommands, mdCommands, rowAxis, rowCount, rowLabels, rowLevels, rowUpAxisLabels, startColumn, startRow
 
Constructor Summary
MDTable()
          Construct a new Table object
MDTable(String name, ModelInterface model)
          Construct a new Table object
 
Method Summary
 String getDoubleLeftArrowSource()
          Returns the source source location of the double left arrow image used in the table.
 String getDoubleRightArrowSource()
          Returns the source source location of the double right arrow image used in the table.
 String getFormAction()
          Returns the value placed on the FORM tags ACTION= attribute.
 String getFormMethod()
          Returns the value placed on the FORM tags METHOD= attribute.
 boolean getInternetExplorerTableFormatEnabled()
          Returns whether the HTML table will be created using methods that create a nicer looking table under Internet Explorer.
 String getLeftArrowSource()
          Returns the source source location of the left arrow image used in the table.
 int getNavigationBarOrientation()
          Returns the current setting for navigation bar orientation.
 String getRightArrowSource()
          Returns the source source location of the right arrow image used in the table.
 String getUpArrowSource()
          Returns the source source location of the up arrow image used in the table.
 void setArrowLocations(String upArrowSrc, String leftArrowSrc, String doubleLeftArrowSrc, String rightArrowSrc, String doubleRightArrowSrc)
          This is a convenience method to set all arrow images with one method call.
 void setDoubleLeftArrowSource(String src)
          Sets the source source location of the double left arrow image used in the table.
 void setDoubleRightArrowSource(String src)
          Sets the source location of the double right arrow image used in the table.
 void setFormAction(String href)
          Sets the value placed on the FORM tags ACTION= attribute.
 void setFormMethod(String method)
          Sets the value placed on the FORM tags METHOD= attribute.
 void setInternetExplorerTableFormatEnabled(boolean enabled)
          Sets whether or not the HTML table will be created using methods that create a nicer looking table under Internet Explorer.
 void setLeftArrowSource(String src)
          Sets the source source location of the left arrow image used in the table.
 void setNavigationBarOrientation(int orientation)
          Returns the current setting for navigation bar orientation.
 void setRightArrowSource(String src)
          Sets the source source location of the right arrow image used in the table.
 void setUpArrowSource(String loc)
          Sets the source source location of the up arrow image used in the table.
protected  void writeColumnHeadings(PrintWriter out)
          Writes the column headings.
protected  void writeRows(PrintWriter out)
          Writes all rows of the formatted table.
protected  void writeTableFooter(PrintWriter out)
          Writes the table footer
protected  void writeTableHeader(PrintWriter out)
          Writes the table header
protected  void writeTableNavigationBars(PrintWriter out)
          Writes the table navigation bars.
protected  void writeTableTitles(PrintWriter out)
          Writes the table subset information.
 
Methods inherited from class com.sas.servlet.beans.mdtable.BaseMDTable
buildMDCommand, buildMDCommand, executeCommand, getBorderWidth, getCellPadding, getCellSpacing, getMaxColumns, getMaxRows, getModelInformation, getRequiredInterfaces, getWidth, getWidthPercentage, initialize, setBorderWidth, setCellPadding, setCellSpacing, setMaxColumns, setMaxRows, setModelInterface, setWidth, setWidthPercentage, toString, write, writeColumnHeadings, writeColumnHeadings, writeRows, writeRows, writeTable, writeTableFooter, writeTableFooter, writeTableHeader, writeTableHeader, writeTableNavigationBars, writeTableNavigationBars, writeTableTitles, writeTableTitles
 
Methods inherited from class com.sas.servlet.beans.BaseTransformation
getCustomAttributes, getDescription, getName, getParent, getRequest, getResponse, setCustomAttributes, setDescription, setName, setParent, setRequest, setResponse, write, write, write
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getExtendedBeanInfo, getLinkInfo, getModelInterface, getResources, getStringResource, getViewInterfaceSupportInfo, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MDTable

public MDTable()
Construct a new Table object

MDTable

public MDTable(String name,
               ModelInterface model)
Construct a new Table object
Parameters:
name - The field name
model - The model used for this viewer
Method Detail

getFormAction

public String getFormAction()
Returns the value placed on the FORM tags ACTION= attribute.
Returns:
the value of the ACTION= attribute on the FORM tag.

setFormAction

public void setFormAction(String href)
Sets the value placed on the FORM tags ACTION= attribute.
Parameters:
the - value of the ACTION= attribute on the FORM tag.

getInternetExplorerTableFormatEnabled

public boolean getInternetExplorerTableFormatEnabled()
Returns whether the HTML table will be created using methods that create a nicer looking table under Internet Explorer.
Returns:
true if the table is optimized for Internet Explorer, false if not.

setInternetExplorerTableFormatEnabled

public void setInternetExplorerTableFormatEnabled(boolean enabled)
Sets whether or not the HTML table will be created using methods that create a nicer looking table under Internet Explorer. If enabled and the table is viewed under NetScape the table may not be centered on the page correctly.
Parameters:
enabled - true if the table is optimized for Internet Explorer, false if not.

getFormMethod

public String getFormMethod()
Returns the value placed on the FORM tags METHOD= attribute. If not set the default value is GET.
Returns:
the value of the METHOD= attribute on the FORM tag.

setFormMethod

public void setFormMethod(String method)
Sets the value placed on the FORM tags METHOD= attribute. If not set the default value is GET.
Parameters:
method - - the value of the METHOD= attribute on the FORM tag.

getUpArrowSource

public String getUpArrowSource()
Returns the source source location of the up arrow image used in the table. The source source location can either be an absolute or relative URL.
Returns:
the source source location of the up arrow.

getRightArrowSource

public String getRightArrowSource()
Returns the source source location of the right arrow image used in the table. The source source location can either be an absolute or relative URL.
Returns:
the source source location of the right arrow.

getDoubleRightArrowSource

public String getDoubleRightArrowSource()
Returns the source source location of the double right arrow image used in the table. The source source location can either be an absolute or relative URL.
Returns:
the source source location of the double right arrow.

getLeftArrowSource

public String getLeftArrowSource()
Returns the source source location of the left arrow image used in the table. The source source location can either be an absolute or relative URL.
Returns:
the source source location of the left arrow.

getDoubleLeftArrowSource

public String getDoubleLeftArrowSource()
Returns the source source location of the double left arrow image used in the table. The source source location can either be an absolute or relative URL.
Returns:
the source source location of the double left arrow.

setUpArrowSource

public void setUpArrowSource(String loc)
Sets the source source location of the up arrow image used in the table. The source source location can either be an absolute or relative URL.
Parameters:
loc - the source source location of the up arrow.

setLeftArrowSource

public void setLeftArrowSource(String src)
Sets the source source location of the left arrow image used in the table. The source source location can either be an absolute or relative URL.
Parameters:
src - the source source location of the left arrow.

setDoubleLeftArrowSource

public void setDoubleLeftArrowSource(String src)
Sets the source source location of the double left arrow image used in the table. The source source location can either be an absolute or relative URL.
Parameters:
src - the source source location of the double left arrow.

setRightArrowSource

public void setRightArrowSource(String src)
Sets the source source location of the right arrow image used in the table. The source source location can either be an absolute or relative URL.
Parameters:
src - the source source location of the right arrow.

setDoubleRightArrowSource

public void setDoubleRightArrowSource(String src)
Sets the source location of the double right arrow image used in the table. The source location can either be an absolute or relative URL.
Parameters:
src - the source location of the double right arrow.

setArrowLocations

public void setArrowLocations(String upArrowSrc,
                              String leftArrowSrc,
                              String doubleLeftArrowSrc,
                              String rightArrowSrc,
                              String doubleRightArrowSrc)
This is a convenience method to set all arrow images with one method call. The source locations can either be an absolute or relative URL.
Parameters:
upArrowSrc - the source location of the up arrow
leftArrowSrc - the source location of the left arrow
doubleLeftArrowSrc - the source location of the double left arrow
rightArrowSrc - the source location of the right arrow
doubleRightArrowSrc - the source location of the double right arrow

getNavigationBarOrientation

public int getNavigationBarOrientation()
Returns the current setting for navigation bar orientation. Valid values are com.sas.geometry.SideOrientation.TOP, com.sas.geometry.SideOrientation.BOTTOM, and com.sas.geometry.SideOrientation.ALL. com.sas.geometry.SideOrientation.ALL will display navigation bars at the top of the page and the bottom of the page. If not set the default is to display the naviagation bars at the bottom of the table.
Returns:
position of navigation bars

setNavigationBarOrientation

public void setNavigationBarOrientation(int orientation)
Returns the current setting for navigation bar orientation. Valid values are com.sas.geometry.SideOrientation.TOP, com.sas.geometry.SideOrientation.BOTTOM, and com.sas.geometry.SideOrientation.ALL. com.sas.geometry.SideOrientation.ALL will display navigation bars at the top of the page and the bottom of the page. If not set the default is to display the naviagation bars at the bottom of the table.
Parameters:
orientation - orientation of navigation bar(s)

writeTableNavigationBars

protected void writeTableNavigationBars(PrintWriter out)
                                 throws IOException
Writes the table navigation bars. If this method is overridden the developer will most likely need to information generated by the getModelInformation method.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
writeTableNavigationBars in class BaseMDTable
See Also:
BaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)

writeTableTitles

protected void writeTableTitles(PrintWriter out)
                         throws IOException
Writes the table subset information. If this method is overridden the developer will most likely need to information generated by the getModelInformation method.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
writeTableTitles in class BaseMDTable
See Also:
BaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)

writeTableHeader

protected void writeTableHeader(PrintWriter out)
                         throws IOException
Writes the table header
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
writeTableHeader in class BaseMDTable

writeTableFooter

protected void writeTableFooter(PrintWriter out)
                         throws IOException
Writes the table footer
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
writeTableFooter in class BaseMDTable

writeColumnHeadings

protected void writeColumnHeadings(PrintWriter out)
                            throws IOException
Writes the column headings. If this method is overridden the developer will most likely need to information generated by the getModelInformation method.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
writeColumnHeadings in class BaseMDTable
See Also:
BaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)

writeRows

protected void writeRows(PrintWriter out)
                  throws IOException
Writes all rows of the formatted table. If this method is overridden the developer will most likely need to information generated by the getModelInformation method.
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
writeRows in class BaseMDTable
See Also:
BaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)


Version: 1.2.20000317.001 Formatted: 2000/07/06 15:57:33PM