This sample demonstrates how to implement a custom ViewTool, called QueryTool, and to use it standalone with the ThinCrosstab. The implementation class (BIQueryToolServlet) inherits user login functionality from BIServlet (sample 1). QueryTool demonstrates how the view's query can be modified by applying simple conditions such as "Select Cities where Sales are in top 10".
If you have not already done so, you must perform several installation
and configuration tasks, then open the workspace servlet\Servlet.jws
under the samples
directory within JDeveloper. All the necessary
files for this sample can be found in the custom_query_tool.jpr
project under the Servlet.jws
workspace.
The modification of the View's Query is done when the QueryTool processes QueryTool.QUERY_EVENT. In method handleQueryEvent()
the QueryTool reads the following event parameters:
QueryTool.DIMENSION_PARAMETER
QueryTool.HIERARCHY_PARAMETER
QueryTool.LEVEL_PARAMETER
QueryTool.OPERATOR_PARAMETER
QueryTool.NUMBER_PARAMETER
Based on the QueryTool.OPERATOR_PARAMETER, the QueryTool creates oracle.dss.selection.step.TopBottomStep or oracle.dss.selection.step.MeasValStep, and then replaces the Selection for the specified dimension with a new Selection that contains the created Step:
Create a new TopBottomStep (e.g. "Select Top 10 Products based on Sales")
if (m_operator.equals(QueryTool.OPERATOR_TOP))
{
step = new TopBottomStep(m_dimension, m_hierarchy, levels, m_measure, TopBottomStep.TOP,
new Integer(m_number), false);
}
Create a new TopBottomStep (e.g. "Select Bottom 10 Products based on Sales")
else if (m_operator.equals(QueryTool.OPERATOR_BOTTOM))
{
step = new TopBottomStep(m_dimension, m_hierarchy, levels, m_measure, TopBottomStep.BOTTOM,
new Integer(m_number), false);
}
Create a new MeasValStep (e.g. "Select Products where Sales > 1,000,000")
else if (m_operator.equals(QueryTool.OPERATOR_GREATER))
{
step = new MeasValStep(m_dimension, m_measure, m_hierarchy, levels, MeasValStep.OP_GREATER,
new Float(m_number));
}
Create a new MeasValStep (e.g. "Select Products where Sales < 1,000,000")
else if (m_operator.equals(QueryTool.OPERATOR_LESS))
{
step = new MeasValStep(m_dimension, m_measure, m_hierarchy, levels, MeasValStep.OP_LESS,
new Float(m_number));
}
To simplify the user interface, this sample does not provide the user with a way to fully qualify the Measure for the Query condition. Instead, the Step is initialized with the QDR for the first slice on the column edge of the Query.
After initializing the Step, QueryTool creates a new Selection for the specified dimension, adds the new Step and replaces the existing Selection for that dimension on the Query:
Create a new Selection for the specified dimension
Selection selection = new Selection(m_dimension);
Set the selected hierarchy on the Selection
selection.setHierarchy(m_hierarchy);
Add the new Step to the Selection
selection.addStep(step);
Apply the new selection to the current Query
query.applySelection(selection);
BIQueryToolServlet extends BIServlet from Sample 1 and provides implementation
for the processRequest()
method, called by the base class after
a successful user login. This method renders the actual HTML page that contains
a Crosstab and a QueryTool by executing the following sequence of actions:
Ensure that ThinCrosstab and QueryTool thin beans are stored
on the HTTP session and registered with ServletRequestHandler (see initializeThinBeans()
).
Ask ServletRequestHandler to handle potential application events (such as modifying the query of the view, drilling, paging, etc.)
Render simple HTML and use UIX components to display ThinCrosstab and QueryTool.
To run the BIQueryToolServlet example within JDeveloper, simply right-click BIQueryToolServlet.java under custom_query_tool.jpr, and choose Run BIQueryToolServlet.java. When the application appears in a browser, enter the username and password of the user that owns the BI Beans Catalog (e.g. BIBCAT). When the crosstab appears, drill down on the dimensions to expand the crosstab. Then, you can use the query tool to filter the values on the crosstab.
![]() |
|
---|---|
Copyright © 2002, 2003 Oracle. All Rights Reserved. |
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. |