4. Linking Presentations

Exercise Objectives

Learn how to link the queries of a graph and a crosstab.

Exercise Description

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.

Exercise Tasks

Update the application

To add the dual report menu item:

  1. In the System-Navigator pane in JDeveloper, right-click BIApplication1.java and choose UI Editor.
  2. If the Structure pane is not open, then press Ctrl+Shift+S to open it. In the Structure pane, expand Menu.
  3. Select m_menubar. Notice that the UI Editor is refreshed to allow menu editing.
  4. In the UI Editor, select Tools. Notice that the menu items appear.
  5. Select Change View and enter Dual Report in the box below the Crosstab submenu item.
  6. In the UI Editor, select Dual Report.
  7. In the Property Inspector pane, enter m_mnuDual as the value for the name property.
  8. From the File menu, choose Save.

To add custom code to support the linking of presentations in a dual report:

  1. In the System-Navigator pane, right-click BIApplication1.java and choose Code Editor.
  2. From the Search menu, choose Find to search for the following line of code: public void setViewType(int vt) to locate the setViewType method.
  3. You must add a new case within the 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.
  4. Read the following code thoroughly. It modifies the view so that it is displayed as a linked graph and crosstab. Then, copy and paste the code into the Code Editor at the location that was specified in the previous step:

    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;

  5. You must change the generated 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.
  6. In the displayView method, position the cursor after the following line of code m_pnlView.removeAll(); and press Enter to insert a new line.
  7. Read the following code thoroughly. It resets the grid layout of the panel to a single view. Then, copy and paste the code into the Code Editor at the 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);

  8. In the displayView method, position the cursor after the following line of code: m_pnlView.add(dv); and press Enter to insert a new line.
  9. Read the following code thoroughly. It resets the 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);
    }


  10. From the File menu, choose Save.

To add an Action Listener for the dual view menu item:

  1. In the System-Navigator pane, right-click BIApplication1.java and choose UI Editor.
  2. In the UI Editor, select Tools, then Change Views, and then Dual Report.
  3. In the Property Inspector, select the Events tab at the bottom.
  4. Click the "..." button to the right of the ActionPerformed value.
  5. Enter m_mnuDual_ActionPerformed as the name and choose OK.
  6. In the open Code Editor, enter the following line as the body of the m_mnuDual_actionPerformed method:

    setViewType(VIEW_TYPE_DUAL);

    This code invokes the setViewType method using the parameter VIEW_TYPE_DUAL, which changes the view to a dual report.

  7. Right-click BIApplication1.java and select Make from the popup menu to compile the code. The debug window at the base of the JDeveloper screen should indicate "Successful compilation: 0 errors, 0 warnings".

To run the application:

  1. Right-click BIApplication1.java and choose Run BIApplication1.java to run the application.
  2. From the Tools menu, choose Change View then Dual Report. The crosstab will be changed to a dual report. You will observe that the main panel layout will split into two, one above the other. The crosstab will be displayed in the upper panel and a graph will be displayed in the lower panel.
  3. Because only one view is the original active view (in this case, the crosstab), only that view can be edited using the formatting toolbar. This is only a limitation of the application code and can be modified to work with either of the views. Experiment with opening and closing new presentations. From the File menu, choose Open and then use the combination of features that you have added to the application in each of the exercises.
  4. This concludes all the application code that you will add to your application. When you finish experimenting with your new BI Application, choose Exit from the File menu to return to JDeveloper.

Exercise Summary

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.

3. Customizing BI Objects | Overview | 5. Deploying Java Applications