![]() | ![]() | ![]() | ![]() | ![]() |
The OLAPTableView is a TableView that enables OLAP (Online Analytical Processing) data to be viewed and manipulated in tabular form. The sample creates an OLAPTableViewComposite, which is a TransformationBeanTM that is composed of other TransformationBeans that include the following subcomponents: MenuBar, NavigationBar, OLAPTableView, OLAPDrillState, AppliedFilters, Title, and Footer.
Here are the steps for creating a simple OLAPTableView:
The code shown on the Full Code tab will create an OLAPDataSet and display a default OLAPTableViewComposite with that model.
The sample is based on the Model 2 Servlet template that is available in SAS® AppDev Studio. For simplicity, this sample uses its own static data model for the OLAPTableView, which means that it does not enable the actions that are available with live data such as sorting, expanding, and totals. In most real-world use cases, users will connect to live data and not create their own data model. For more information about how to connect the OLAPTableView, see Sample 26014.
Customizations
This sample contains the following customizations:
Set the columnPageSize and rowPageSize properties on the OLAPTableView tag:
<sas:OLAPTableViewComposite id="OLAPTableView1" model="model" scope="session" actionProvider="actionProvider">
<sas:OLAPTableView columnPageSize="4" rowPageSize="4"/>
</sas:OLAPTableViewComposite>
|
Change the sas:OLAPTableView tag to have a separate end tag, and insert the following sas:StyleMapKey tags in the body of the sas:OLAPTableView tag:
<sas:OLAPTableViewComposite id="OLAPTableView1" model="model" scope="session" actionProvider="actionProvider">
<sas:OLAPTableView columnPageSize="4" rowPageSize="4">
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_HEADER_STYLE"
classid="OLAPTableRowHeader" style="background-color: lightgreen;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_HEADER_STYLE"
classid="OLAPTableColumnHeader" style="background-color: lightblue;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_MEASURE_HEADER_STYLE"
classid="OLAPTableColumnMeasureHeader" style="background-color: aqua;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_MEASURE_HEADER_STYLE"
classid="OLAPTableRowMeasureHeader" style="background-color: yellow;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_TITLE_HEADER_STYLE"
classid="OLAPTableRowTitleHeader" style="background-color: lime;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_EMPTY_ROW_TITLE_HEADER_STYLE"
classid="OLAPTableEmptyRowTitleHeader" style="background-color: lime;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_TITLE_HEADER_STYLE"
classid="OLAPTableColumnTitleHeader" style="background-color: lightskyblue;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_DATA_STYLE"
classid="OLAPTableData" style="background-color: orange;"/>
</sas:OLAPTableView>
</sas:OLAPTableViewComposite>
|
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Tip: For help with building a Web application project and testing a Web application, see SAS Note 32218.
<%@ taglib uri="http://www.sas.com/taglib/sas" prefix="sas" %>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<link href="styles/sasComponents.css" rel="STYLESHEET" type="text/css">
</head>
<body>
<sas:OLAPTableViewComposite id="olapTableView"
model="olapModel"
actionProvider="actionProvider"
scope="session"/>
</body>
</html>
|
<%@ taglib uri="http://www.sas.com/taglib/sas" prefix="sas" %>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<link href="styles/sasComponents.css" rel="STYLESHEET" type="text/css">
</head>
<body>
<sas:OLAPTableViewComposite id="olapTableView"
model="olapModel"
actionProvider="actionProvider"
scope="session">
<sas:OLAPTableView columnPageSize="4" rowPageSize="4"/>
</sas:OLAPTableViewComposite>
</body>
</html>
|
<%@ taglib uri="http://www.sas.com/taglib/sas" prefix="sas" %>
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<link href="styles/sasComponents.css" rel="STYLESHEET" type="text/css">
</head>
<body>
<sas:OLAPTableViewComposite id="olapTableView"
model="olapModel"
actionProvider="actionProvider"
scope="session">
<sas:OLAPTableView columnPageSize="4" rowPageSize="4">
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_HEADER_STYLE"
classid="OLAPTableRowHeader" style="background-color: lightgreen;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_HEADER_STYLE"
classid="OLAPTableColumnHeader" style="background-color: lightblue;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_MEASURE_HEADER_STYLE"
classid="OLAPTableColumnMeasureHeader" style="background-color: aqua;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_MEASURE_HEADER_STYLE"
classid="OLAPTableRowMeasureHeader" style="background-color: yellow;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_TITLE_HEADER_STYLE"
classid="OLAPTableRowTitleHeader" style="background-color: lime;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_EMPTY_ROW_TITLE_HEADER_STYLE"
classid="OLAPTableEmptyRowTitleHeader" style="background-color: lime;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_TITLE_HEADER_STYLE"
classid="OLAPTableColumnTitleHeader" style="background-color: lightskyblue;"/>
<sas:StyleMapKey key="OLAPTABLEVIEW_DATA_STYLE"
classid="OLAPTableData" style="background-color: orange;"/>
</sas:OLAPTableView>
</sas:OLAPTableViewComposite>
</body>
</html>
|
package servlets;
public class Model2ExampleControllerServlet.java ...sas_actionProvider.setControllerURL(request.getContextPath()+ "/Model2Example");
RequestDispatcher rd = getServletContext().getRequestDispatcher("/Model2ExampleViewer.jsp");
package servlets;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.sas.actionprovider.HttpActionProvider;
import com.sas.storage.olap.AxisInterface;
import com.sas.storage.olap.OLAPException;
import com.sas.storage.olap.TupleElementInterface;
import com.sas.storage.olap.TupleInterface;
import com.sas.storage.olap.embedded.Axis;
import com.sas.storage.olap.embedded.OLAPDataSet;
import com.sas.storage.olap.embedded.ResultSet;
import com.sas.storage.olap.embedded.ResultSetMetadata;
import com.sas.storage.olap.embedded.Tuple;
import com.sas.storage.olap.embedded.TupleElement;
public class Model2ExampleControllerServlet extends
javax.servlet.http.HttpServlet {
private static final String ACTION_PROVIDER = "actionProvider";
private static final String SAS_MODEL = "olapModel";
// Declare a default version ID since parent class implements
// java.io.Serializable
private static final long serialVersionUID = 1L;
/*
* doPost() Respond to the Post message.
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Note: Calling doGet to provide same behavior to POST and GET HTTP
// methods.
doGet(request, response);
}
/*
* doGet() Respond to the Get message.
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Note: Add User DO_GET code here
HttpSession session = request.getSession();
// Setup the ActionProvider
HttpActionProvider actionProvider = null;
synchronized (session) {
if (session != null) {
actionProvider = (HttpActionProvider) session
.getAttribute(ACTION_PROVIDER);
}
// if ActionProvider is null, create one and put it on the session
if (actionProvider == null) {
actionProvider = new HttpActionProvider();
actionProvider.setLocale(request.getLocale());
actionProvider.setControllerURL(request.getContextPath()
+ "/Model2Example");
actionProvider.setName(ACTION_PROVIDER);
// store object in its scope
if (session != null)
session.setAttribute(ACTION_PROVIDER, actionProvider);
}
// else execute the ActionProvider command
else {
actionProvider.executeCommand(request, response, response
.getWriter());
}
}
OLAPDataSet defaultOLAPTableModel = null;
synchronized (session) {
if (session != null) {
defaultOLAPTableModel = (OLAPDataSet) session
.getAttribute(SAS_MODEL);
}
if (null == defaultOLAPTableModel) {
defaultOLAPTableModel = createStaticData();
session.setAttribute(SAS_MODEL, defaultOLAPTableModel);
}
}
RequestDispatcher rd = getServletContext().getRequestDispatcher(
"/Model2ExampleViewer.jsp");
rd.forward(request, response);
}
private OLAPDataSet createStaticData() {
OLAPDataSet defaultOLAPTableModel = null;
try {
TupleInterface tuple1 = new Tuple(new TupleElementInterface[] {
new TupleElement("Candy"), new TupleElement("Sales") });
TupleInterface tuple2 = new Tuple(new TupleElementInterface[] {
new TupleElement("Candy"), new TupleElement("Profits") });
TupleInterface tuple3 = new Tuple(new TupleElementInterface[] {
new TupleElement("Magazines"), new TupleElement("Sales") });
TupleInterface tuple4 = new Tuple(
new TupleElementInterface[] {
new TupleElement("Magazines"),
new TupleElement("Profits") });
TupleInterface tuple5 = new Tuple(
new TupleElementInterface[] {
new TupleElement("North Carolina"),
new TupleElement("Bob") });
TupleInterface tuple6 = new Tuple(new TupleElementInterface[] {
new TupleElement("North Carolina"),
new TupleElement("Mary") });
TupleInterface tuple7 = new Tuple(new TupleElementInterface[] {
new TupleElement("Virginia"), new TupleElement("Jean") });
TupleInterface tuple8 = new Tuple(new TupleElementInterface[] {
new TupleElement("Virginia"), new TupleElement("Joe") });
TupleInterface tuple9 = new Tuple(new TupleElementInterface[] {
new TupleElement("Tennessee"), new TupleElement("Tom") });
TupleInterface tuple10 = new Tuple(new TupleElementInterface[] {
new TupleElement("Tennessee"), new TupleElement("Dave") });
Axis columnAxis = new Axis(AxisInterface.COLUMNS_AXIS, null,
new TupleInterface[] { tuple1, tuple2, tuple3, tuple4 });
columnAxis.setAxisHeaders(new String[] { "Product", "" });
columnAxis.setUniqueLevelNames(new String[] { "[Products]",
"[Measures]" });
Axis rowAxis = new Axis(AxisInterface.ROWS_AXIS, null,
new TupleInterface[] { tuple5, tuple6, tuple7, tuple8,
tuple9, tuple10 });
rowAxis.setAxisHeaders(new String[] { "State", "Name" });
rowAxis.setUniqueLevelNames(new String[] { "[State]", "[Name]" });
AxisInterface[] axes = { columnAxis, rowAxis };
// create an instance of result set metadata with the axes
ResultSetMetadata resultSetMetadata = new ResultSetMetadata(axes);
ResultSet resultSet = new ResultSet();
resultSet.setResultSetMetadata(resultSetMetadata);
Object[] values = new Object[] { "500", "150", "200", "75", "450",
"105", "300", "85", "335", "80", "120", "25", "570", "175",
"150", "35", "475", "125", "205", "40", "610", "230", "95",
"30" };
resultSet.setCells(0, 23, values);
defaultOLAPTableModel = new OLAPDataSet(resultSet);
} catch (OLAPException oe) {
oe.printStackTrace();
}
return defaultOLAPTableModel;
}
}
|
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.


| Type: | Sample |
| Date Modified: | 2008-08-29 15:34:08 |
| Date Created: | 2006-01-12 16:43:17 |
| Product Family | Product | Host | Product Release | SAS Release | ||
| Starting | Ending | Starting | Ending | |||
| SAS System | SAS AppDev Studio | Microsoft Windows XP Professional | 3.2 | 9.1 TS1M3 SP4 | ||
| Microsoft Windows Server 2003 Standard Edition | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows Server 2003 Enterprise Edition | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows Server 2003 Datacenter Edition | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows NT Workstation | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows 2000 Professional | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows 2000 Server | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows 2000 Datacenter Server | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft Windows 2000 Advanced Server | 3.2 | 9.1 TS1M3 SP4 | ||||
| Microsoft® Windows® for x64 | 3.2 | 9.1 TS1M3 SP4 | ||||
| Windows Vista | 3.2 | 9.1 TS1M3 SP4 | ||||




