1. Creating a Simple BI JSP Application

Exercise Objectives

The objective of this exercise is to learn the techniques that you need to develop a BI JSP application using predefined BI Beans objects and custom BI JSP tags.

Exercise Description

In JDeveloper, you can create a JSP application easily using custom BI JSP tags. From the component palette, you select tags that you can incorporate into your JSP to build an application quickly. First, use the BIThinSession tag to build a connection to Oracle9i OLAP based on the BI Designer object that you created in the previous tutorial. Then, use the Presentation tag to display a graph and the Toolbar tag to create a toolbar that controls the graph. You will run the application within JDeveloper to preview it.

Exercise Tasks

Create a new empty JSP

  1. Start JDeveloper.
  2. In the System-Navigator pane, click the plus (+) sign beside Workspaces to display a list of existing workspaces.
  3. Click the plus (+) sign beside BIWorkspace.jws to open this workspace, which you created in the previous tutorial.
  4. Select Project1.jpr.
  5. From the File menu, choose New to create a new JDeveloper object within the selected project. The JDeveloper New Wizard appears.
  6. Under Categories, expand the Web Tier node, and select JavaServer Pages (JSP).
  7. Under Items, select JSP Page.
  8. Choose OK.
  9. In the New JSP dialog, enter simpleJSP.jsp as the name of the JSP and accept the default directory for storing the JSP file. Choose Finish.

You have created a new JSP under Project1.jpr. Notice that the Code Editor displays the code of the new JSP. This code includes simple HTML and Java code that displays the current time. A default webXML file (which is required for running the JSP) has also been created.

From the File menu, choose Save All to save the new JSP and its associated XML file.

Add the Oracle 9i OLAP connection

Before you add objects to the JSP application, you must define the OLAP connections and object locations. Use the BIThinSession tag that encapsulates this information and is based on the BIDesigner object (Project1BIDesigner1) that you create previously.

To open the BIThinSession tag wizard:

  1. If the Code Editor is not open for the JSP, then, in the System-Navigator pane, right-click simpleJSP.jsp and choose Code Editor.
  2. Ensure that the Component Palette pane is open. To open this pane, from the View menu, choose Component Palette.
  3. In the Component Palette pane, ensure that the tag type is Business Intelligence Tags. If not, scroll down the list of tag types and select Business Intelligence Tags.
  4. If the available tags are in icon view, right-click any of the icons and choose List View.
  5. Select the BIThinSession icon to add the tag. The JDeveloper BIThinSession tag wizard appears.

To use the BIThinSession tag wizard:

In the BIThinSession tag wizard, you can define the attribute values for the BIThinSession tag.

  1. In the id box, enter simpleApp. Ensure that there are no spaces in id boxes.
  2. Click the configuration box.
  3. Choose the button to the right of the configuration value box to display the Select a BI Designer dialog box.
  4. Select /Project1BIConfig1.xml - [Project1BIDesigner1 - Project1] and choose OK. The configuration value /Project1BIConfig1.xml identifies the XML file that will be used for the OLAP connection.
  5. Do not enter values in the remaining attributes. The default values for these attributes will be used. If you accidentally clicked on any value, select <default>.
  6. Choose Finish to create the tag.

To review the generated BIThinSession tag code:

You can see the generated code in the Code Editor. The following code defines the location of the BI tag library, creates a synchronized session for the application, identifies the connection configuration file to use, and creates a form to hold the BI tags:

<%@ taglib uri="http://xmlns.oracle.com/bibeans" prefix="orabi" %>
...
<%-- Start synchronization of the BI tags --%>
<% synchronized(session){ %>
<orabi:BIThinSession id="simpleApp" configuration="/Project1BIConfig1.xml" >
</orabi:BIThinSession>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>
<body>
<FORM name="BIForm">
<%-- Insert your Business Intelligence tags here --%>
</FORM>

...
<% } %>
<%-- End synchronization of the BI tags --%>

From the File menu, choose Save All to save the JSP application.

Add the graph object to the application

After you have defined the connection information, you are ready to add an object to your application.

To open the Presentation tag wizard:

  1. In the Code Editor, place the cursor on the line below the <%-- Insert your Business Intelligence tags here --%> comment .
  2. In the Component Palette pane, under Business Intelligence Tags, select the Presentation icon to add the tag.

To use the Presentation tag wizard:

In the Presentation tag wizard, you can define the attribute values for the Presentation (Graph) tag.

  1. In the id box, enter simpleGraph.
  2. Click the location box.
  3. To browse for a presentation, click the button that appears to the right of the location box.
  4. Select Sales Analysis Graph, which is the graph that you created previously, and choose OK.
  5. Do not enter values in the remaining attributes. The default values for these attributes will be used.
  6. Choose Finish to create the tag.

To review the code that was generated for the Presentation tag:

In the Code Editor, you can see the following generated code:

For declaring an object

The following code below the <orabi: BIThinSession> tag identifies the graph definition file to display in the JSP:

<orabi:Presentation id="simpleGraph" location="Sales Analysis Graph"/>

For rendering an object

The following code adds hidden fields to maintain the state of the application, and displays the graph.

<orabi:Render targetId="simpleGraph" parentForm="BIForm" />

<%-- The InsertHiddenFields tag adds state fields to the parent form tag --%>
<orabi:InsertHiddenFields parentForm="BIForm" biThinSessionId="simpleApp" />

From the File menu, choose Save All to save the JSP application.

Add a toolbar to the application

After adding a graph to the simple application, you can add a toolbar that contains the essential tools for manipulating the graph. These tools perform tasks such as changing the view type, rotating dimensions, sorting dimension values, and retrieving favorites.

To open the Toolbar tag wizard:

  1. In the Code Editor, place the cursor on the line below the <%-- Insert your Business Intelligence tags here --%> comment.
  2. In the Component Palette pane, under Business Intelligence Tags, scroll and select the Toolbar icon to add the tag.

To use the Toolbar tag wizard:

In the Toolbar wizard, you can define the attribute values for the Toolbar tag.

  1. In the id box, enter simpleToolbar.
  2. In the presentationID box, select simpleGraph.
  3. Do not enter values in the remaining attributes.
  4. Choose Finish to create the tag.

To review the generated Toolbar tag code:

In the Code Editor, you can see the generated code. The following code defines the presentation that the toolbar controls (in this case, the referenced presentation is "simpleGraph" that you just created):

<orabi:Toolbar id="simpleToolbar" presentationId="simpleGraph" />

The following lines of code display the toolbar:

<orabi:Render targetId="simpleToolbar" parentForm="BIForm" />

From the File menu, choose Save All to save the JSP application.

Run the application

You have completed the creation of a simple BI application. You can now run the application directly under JDeveloper with its built-in JSP engine.

  1. In the System-Navigator pane, right-click simpleJSP.jsp and choose Run simpleJSP.jsp from the popup menu. A new browser window opens and displays the simple application.
  2. In the browser, directly above the graph, notice the paging control that allows you to change dimension values for each dimension on the Page edge.
  3. In the paging control, under Time, select 2001.
    The browser refreshes and the sales data corresponds to the year 2001.

To use the toolbar:

To select a tool on the toolbar, click the tool.

  1. In the toolbar, select View. The browser refreshes and the View Type tool appears below the toolbar.
  2. In the View Type tool, select Crosstab and choose Go. The browser refreshes and the graph (presentation) now appears as a crosstab.
  3. You can also change the layout by moving the dimensions to different edges (that is, Page, Column or Row). In the toolbar, select Layout. The browser refreshes and the Layout tool appears below the toolbar with the default setting "Move Product Swap With Measure."
  4. In the Layout Tool, without changing the default setting, choose Go. The browser refreshes, the Geography dimension swaps with the Time dimension (that is, the Geography dimension moves to the Page edge and the Time dimension moves to the Column edge).

To terminate the application:

  1. Return to JDeveloper.
  2. From the Run menu, choose Terminate and then Embedded OC4J Server to stop the application.

Exercise Summary

You have built a simple application that allow users to view and analyze critical business information from an Oracle 9i database. Most important, you have accomplished this task easily and quickly using the custom JSP tags without writing a single line of code.

The next exercise "Handling Multiple Presentations" will build on this simple application.

Overview | 2. Handling Multiple Presentations