|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sas.Component | +--com.sas.servlet.beans.BaseTransformation | +--com.sas.servlet.beans.mdtable.BaseMDTable | +--com.sas.servlet.beans.mdtable.html.MDTable
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 |
BaseMDTable
,
MultidimensionalTableV2Interface
, Serialized FormFields 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.BaseTransformation |
getCustomAttributes,
getDescription,
getName,
getParent,
getRequest,
getResponse,
setCustomAttributes,
setDescription,
setName,
setParent,
setRequest,
setResponse,
write,
write,
write |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public MDTable()
public MDTable(String name, ModelInterface model)
name
- The field namemodel
- The model used for this viewerMethod Detail |
public String getFormAction()
public void setFormAction(String href)
the
- value of the ACTION= attribute on the FORM tag.public boolean getInternetExplorerTableFormatEnabled()
public void setInternetExplorerTableFormatEnabled(boolean enabled)
enabled
- true if the table is optimized for Internet Explorer, false if not.public String getFormMethod()
public void setFormMethod(String method)
method
- - the value of the METHOD= attribute on the FORM tag.public String getUpArrowSource()
public String getRightArrowSource()
public String getDoubleRightArrowSource()
public String getLeftArrowSource()
public String getDoubleLeftArrowSource()
public void setUpArrowSource(String loc)
loc
- the source source location of the up arrow.public void setLeftArrowSource(String src)
src
- the source source location of the left arrow.public void setDoubleLeftArrowSource(String src)
src
- the source source location of the double left arrow.public void setRightArrowSource(String src)
src
- the source source location of the right arrow.public void setDoubleRightArrowSource(String src)
src
- the source location of the double right arrow.public void setArrowLocations(String upArrowSrc, String leftArrowSrc, String doubleLeftArrowSrc, String rightArrowSrc, String doubleRightArrowSrc)
upArrowSrc
- the source location of the up arrowleftArrowSrc
- the source location of the left arrowdoubleLeftArrowSrc
- the source location of the double left arrowrightArrowSrc
- the source location of the right arrowdoubleRightArrowSrc
- the source location of the double right arrowpublic int getNavigationBarOrientation()
public void setNavigationBarOrientation(int orientation)
orientation
- orientation of navigation bar(s)protected void writeTableNavigationBars(PrintWriter out) throws IOException
out
- The output streamBaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)
protected void writeTableTitles(PrintWriter out) throws IOException
out
- The output streamBaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)
protected void writeTableHeader(PrintWriter out) throws IOException
out
- The output streamprotected void writeTableFooter(PrintWriter out) throws IOException
out
- The output streamprotected void writeColumnHeadings(PrintWriter out) throws IOException
out
- The output streamBaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)
protected void writeRows(PrintWriter out) throws IOException
out
- The output streamBaseMDTable.getModelInformation(com.sas.sasserver.mdtable.MultidimensionalTableV2Interface)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |