The objective of this exercise is to introduce the basic techniques for customizing a table or crosstab using the BI Beans API.
Just as users want to display graphs that are user-friendly, they also want to display crosstabs and tables that are user-friendly. Previously, in these tutorials, you changed the default look-and-feel of a crosstab. Now, you will see how to define rules manually for displaying cells based on data values. This technique helps application users to identify exception data values easily.
<%@page ... ">
tag import
attribute: oracle.dss.dataView.managers.ViewStyle
oracle.dss.thin.beans.crosstab.ThinCrosstab
oracle.dss.rules.discriminator.NumberValueDiscriminator
oracle.dss.rules.DiscriminatorRule
oracle.dss.rules.RuleBundle
oracle.dss.gridView.GridViewDatabodyStyleManager
java.util.Vector
java.awt.Color
<%@ page contentType="text/html;charset=WINDOWS-1252" import="oracle.dss.thin.beans.graph.ThinGraph,oracle.dss.thin.beans.graph.ImagemapAction,oracle.dss.dataView.managers.ViewStyle,oracle.dss.thin.beans.crosstab.ThinCrosstab,oracle.dss.rules.discriminator.NumberValueDiscriminator,oracle.dss.rules.DiscriminatorRule,oracle.dss.rules.RuleBundle,oracle.dss.gridView.GridViewDatabodyStyleManager,java.util.Vector,java.awt.Color"
%>
</orabi:BIThinSession>
tag: <%
// Define a new crosstab cell-viewing style
ViewStyle vsWarningCell = new ViewStyle();
// Define the background to be red
vsWarningCell.setBackground(Color.red);
// Set an image to the cell
vsWarningCell.setGraphicImageIndex(0);
// Define the image
((ThinCrosstab)simpleCrosstab).setGraphicImagePath(0,"warning.gif");
// Define a new rule that applies when the data value is below 50,000
NumberValueDiscriminator dscLow = new NumberValueDiscriminator(50000.0, NumberValueDiscriminator.LT);
DiscriminatorRule drLow = new DiscriminatorRule();
// Set the new rule
drLow.setDiscriminator(dscLow);
drLow.setFixedMergeable(vsWarningCell);
// Define a cell data bundle
RuleBundle rbLow = new RuleBundle();
// Add the new rule to the bundle
rbLow.addRule(drLow);
// Use the GridViewDatabodyStyleManager to apply the new bundle with
the
new rule to the data cells
GridViewDatabodyStyleManager gvsm = ((ThinCrosstab)simpleCrosstab).getGridViewDatabodyStyleManager();
Vector rbMgrBundle = gvsm.getBundles();
// if no bundle exists, add the new bundle
if (rbMgrBundle==null) {
Vector rbVector = new Vector();
rbVector.addElement(rbLow);
gvsm.setBundles(simpleCrosstab, rbVector); }
// otherwise, append the new bundle
else {
rbMgrBundle.addElement(rbLow);
gvsm.setBundles(simpleCrosstab, rbMgrBundle); }
%>
You added custom formatting to a simple crosstab. Now, run the application to see the difference that results from this formatting.
You added data-dependent cell-level formatting rules to a crosstab. With this additional functionality, users can easily identify exception data for more detailed analysis.
3. Customizing Graph Properties | Overview | 5. Building a BI Beans Catalog Browser