Another way data can be fed to a ReportBlox is via a RDBResultSetDataBlox. RDBResultSetDataBlox allows you to create a relational report using the RDBResultSet returned from an existing DataBlox. DataBlox provides data to user interface Blox such as PresentBlox, GridBlox, and ChartBlox (tags for these Blox are in the Blox Tag Library, available with the <%@ taglib uri="bloxtld" prefix="blox" taglib directive). DataBlox cannot provide data directly to ReportBlox. However, RDBResultSet returned from a DataBlox can be used as the source of data for Relational Reporting via RDBResultSetDataBlox. This is useful for applications where relational details for data in a GridBlox cell from a multidimensional data source can be presented in an attractive, easy-to-read layout.
Alphablox’s drill-through support for Microsoft® Analysis Services data sources in GridBlox and DataBlox, for example, uses a RDBResultSetDataBlox that takes the DataBlox’s RDBResultSet to generate a relational report with ReportBlox. You simply set the GridBlox drillThroughEnable property to true and no custom code is needed. When users choose to drill through from a data cell, relational detail for the cell is displayed in a pre-formatted report using ReportBlox.
For custom report, you can supply your own JSP containing a ReportBlox formatted to you liking. A live example is available in the MSAS version of Blox Sampler, under the Retrieving Data section.
The JSP containing the ReportBlox may looks as follows:
<%@ taglib uri="bloxreporttld" prefix="bloxreport" <html> <head> <link rel="stylesheet" href="/AlphabloxServer/theme/report.css" /> </head> <body> <bloxreport:report id="drillThroughFromDataBlox" ...>
<bloxreport:rdbResultSetData
bloxRef="myDataBlox"
columnCoordinate="<%= request.getParameter(\"colIndex\") "
rowCoordinate="<%= request.getParameter(\"rowIndex\") "
/>
<%--further data manipulation and report formatting--
...
</bloxreport:report>
</body>
</html>
The value for the bloxRef attribute should be the id of the DataBlox defined in the calling JSP. The colIndex and rowIndex parameters are passed in from a scriptlet or Java™ class from the DHTML client in the calling JSP.
<blox:data id="myDataBlox" dataSourceName="QCC-MSAS" selectableSlicerDimensions="Measures" query="yourQueryString"/>
<%@ taglib uri="bloxtld" prefix="blox"
<%@ taglib uri='bloxuitld' prefix='bloxui'
...
<body>
<blox:present id="myPresentBlox"
width="700"
height="580">
<blox:data bloxRef="myDataBlox"/>
<blox:grid drillThroughEnabled="true" />
<bloxui:actionFilter
className="<%= myCustomDrillThrough.class.getName() "
componentName="dataAdvancedDrillThrough" />
</blox:present>
...
import com.alphablox.blox.uimodel.core.grid.GridCell; import com.alphablox.blox.uimodel.tags.IActionFilter; ...
public class myCustomDrillThrough implements IActionFilter
{
public void actionFilter( DataViewBlox blox, Component component )
throws Exception {
GridBrixModel grid =
((PresentBloxModel)blox.getBloxModel()).getGrid();
GridCell[] cells = grid.getSelectedCells();
// Make sure that a single data cell is selected
if ( cells.length != 1 || cells[0].isRowHeader() ||
cells[0].isColumnHeader() || !(cells[0] instanceof GridBrixCellModel ))
{
MessageBox.message( component, "Error", "You must select a
single data cell to drill through" );
return;
}
GridBrixCellModel cell = (GridBrixCellModel)cells[0];
int rowIndex = cell.getNativeRow();
int colIndex = cell.getNativeColumn();
String bloxName = blox.getBloxName();
String urlStr = "myDrillThrough.jsp?bloxRef="+bloxName;
urlStr += "&colIndex=";
urlStr += colIndex;
urlStr += "&rowIndex=";
urlStr += rowIndex;
String timestamp = String.valueOf(System.currentTimeMillis());
urlStr += "&reportName=";
urlStr = urlStr + "reportBlox"+timestamp;
ClientLink link = new ClientLink( urlStr,
"reportBlox"+timestamp);
component.getDispatcher().showBrowserWindow( link );
}
}
For a complete example, see the Retrieving Data section under Blox Sampler.
<blox:data
<blox:present id="myPresentBlox"
mayscriptEnabled="true"
width="700"
height="580">
<blox:data
bloxRef="myDataBlox"/>
<blox:grid
drillThroughEnabled="true"
eventTriggerDrillThrough="multipleDTWindows"/>
</blox:present>
...
<head>
<blox:header/>
<script language="JavaScript">
function multipleDTWindows(var1,var2,var3) {
var bloxName;
var colIndex;
var rowIndex;
var eventObj = var1;
bloxName = "myDataBlox";
colIndex = eventObj.getEventProperty(eventObj, "column");
rowIndex = eventObj.getEventProperty(eventObj, "row");
var urlStr = "someReportBlox.jsp?bloxRef="+bloxName;
urlStr += "&colIndex=";
urlStr += colIndex;
urlStr += "&rowIndex=";
urlStr += rowIndex;
var currentDate = new Date();
var timestamp = currentDate.getTime();
urlStr += "&reportName=";
urlStr = urlStr + "reportBlox"+timestamp;
window.open(urlStr,"reportBlox"+timestamp);
return false;
}
</script>
</head>
For a complete example, see the Retrieving Data section in Blox Sampler.