Learn how to link the queries of a graph and a crosstab.
You will update the menus to add a menu item for displaying a linked graph and crosstab. When you finish this exercise, you will be able to see data that is presented in a crosstab, graph, or linked graph and crosstab. A linked graph and crosstab dual report is helpful for detailed reporting and analysis.
Dual Report
in
the box below the Crosstab submenu item.m_mnuDual
as the value
for the name property.public void setViewType(int vt)
to locate the setViewType
method.setViewType
method to display the
view as a linked graph and crosstab. Search and position the cursor above
the following line of code:
case VIEW_TYPE_GRAPH:
within the setViewType
method.
case VIEW_TYPE_DUAL:
// Set the DualView variable to true.
m_DualView=true;
// If the Active View is a crosstab, then create the graph.
if (m_activeView instanceof Crosstab)
{
if (m_GraphView == null ) {
// Create a Graph and set paging control visible
Graph graph = new Graph();
graph.setPagingControlVisible(true);
// Add to Graph Cache
m_GraphView = graph;
}
// Use the Datasource of the Active View
m_GraphView.setDataSource(m_activeView.getDataSource());
}
// If the Active View is a graph, then create the crosstab.
else if (m_activeView instanceof Graph) {
if (m_CrosstabView == null ) {
// Create a Crosstab and set paging control
visible
Crosstab crosstab = new Crosstab();
crosstab.setPagingControlVisible(true);
// Add to the Crosstab Cache
m_CrosstabView = crosstab;
}
// Use the Datasource of the Active View
m_CrosstabView.setDataSource(m_activeView.getDataSource());
}
// Display the views
displayView(null, m_activeView);
break;
displayView
method
to handle dual views. From the Search menu, choose Find to search
for the following code: public void displayView(String strPath, Dataview dv)
in the Code Editor. displayView
method, position the cursor after the following line of code
m_pnlView.removeAll();
and press Enter to insert a new line.// Create a new GridLayout for the Panel
GridLayout grid = new GridLayout();
// Set the GridLayout with 2 rows for a dual view or 1 row for a single view
depending on the m_DualView variable
if (m_DualView)
grid.setRows(2);
else
grid.setRows(1);
grid.setColumns(1);
m_pnlView.setLayout(grid);
displayView
method, position the cursor after the following line of code:
m_pnlView.add(dv);
and press Enter to insert a new line.m_dualView
variable
and adds the second view. Then, copy and paste the code into the Code Editor
at the new line:// For a dual view
if (m_DualView) {
// Reset the m_DualView variable to false
m_DualView=false;
// Add the graph if the active view is a crosstab or add the crosstab if the
active view is a graph
if (m_activeView instanceof Crosstab) m_pnlView.add(m_GraphView);
else if (m_activeView instanceof Graph) m_pnlView.add(m_CrosstabView);
}
m_mnuDual_ActionPerformed
as the name and choose OK.m_mnuDual_actionPerformed
method:setViewType(VIEW_TYPE_DUAL);
setViewType
method using the parameter
VIEW_TYPE_DUAL, which changes the view to a dual report.In this exercise, you learned how to add multiple views to a page and link the data selections of these views.
In the next section, you will investigate deploying the application that you have developed.