Legal | Privacy
Adding a BI Beans Graph in an ADF Business Components/JSP/Struts Application

Adding a BI Beans Graph in an ADF Business Components/JSP/Struts Application

This lesson shows how you can graphically display some of the information in your application.

Topics

This lesson will discuss the following:

Overview
Prerequisites
Step 1 - Creating a Business Service with ADF Business Components

Step 2 - Creating a Struts Project for JSP

Step 3 - Customizing the Graph Component
Step 4 - Running the Application

Step 5 - Changing the Graph Type

Summary

This exercise takes approximately 45 minutes to complete.

Move your mouse over this icon to show all screenshots. You can also move your mouse over each individual icon to see only the screenshot associated with it.

Overview

This lesson describes the steps to create a JSP-Struts application with ADF Business Components. The application built in this script is a master view with one detail, where the detail is rendered as a Business Intelligence Beans Graph (BI Graph).

Back to Topic List

You want to graphically represent some portion of an application that you are developing.

Prerequisites

Back to Topic List

In order for this lesson to work successfully, you will need to have performed the following:

1.

Install Oracle JDeveloper10g.

 

2.

Install the sample schemas and create a connection to the HR or HR8 schema to use in this lesson. See Installing the Sample Schemas and Establishing a Database Connection.

 

Step 1 - Creating a Business Service with ADF Business Components

Back to Topic List

Java Server Pages can be used with any business service such as ADF Business Components, TopLink, Enterprise Java Beans, Web services and Java Beans. ADF Business Components is used in this topic as an example. After finishing this exercise you may want to practice what you've learned by using one of the other business services.

In this step you create a new application workspace and then create an ADF Business Components model that is based on the Departments and Employees database tables in the HR schema. To create a business service with ADF business components, perform the following steps:

1.

In the Application Navigator, right mouse click on the Applications node. Select New Application Workspace from the context menu.

Move your mouse over this icon to see the image

 

2.

Enter an Application Name of BIBeansApp. As an Application Template select Web Application [Default]. This sets the technologies scope to only those technologies that are commonly used when building JSP-Struts applications.

Move your mouse over this icon to see the image

Click OK.. This creates an application workspace with two empty projects, ViewController and Model.

 

3.

You will create the Business Component mode in the Model project. Right-click the Model project in the Application Navigator, then select New from the context menu.

Move your mouse over this icon to see the image

 

4.

The technologies shown in the New Gallery are determined by the application template that you chose when you created the workspace.

Expand the Business Tier node. Select Business Components in the Categories list and Business Components from Tables in the Items list.

Move your mouse over this icon to see the image

Click OK.

 

5.

In the connection dialog select the HR connection and click OK. In this example, the connection is named MyHRConn, but you can use any database connection to the HR or HR8 schema. For information on how to set up this connection, see Prerequisites.

Move your mouse over this icon to see the image

 

6.

If the Welcome page of the Create Business Components from Tables wizard is displayed, click Next.

In the Entity Objects page of the wizard select (Control-click) the Departmentsand Employees tables in the Available list. Click the Copy button Copy button to move the selected tables to the Selected list on the right.

Move your mouse over this icon to see the image

Click Next.

 

7.

In the View Objects page click the Add All button Copy All button to move both entries to the Selected list on the right. This defines both selected Entity Objects as the source of View Objects.

Move your mouse over this icon to see the image

Click Next.

 

8.

In the Application Module page click Next to accept all default settings.

In the Finish page, click Finish to create the Business Component model.

Move your mouse over this icon to see the image

 

9.

With the Model project selected in the Application Navigator, click the Save button Save button and then Make Make button in the JDeveloper toolbar to save and compile your project.

Move your mouse over this icon to see the image

 

Step 2 - Creating a Struts Project for JSP

Back to Topic List

In this topic you create a JSP page that uses a button bar to navigate through the rows of a master read-only form displaying information about departments. On the same page, detail information about employees of the selected department is shown in a bar chart.

To create this master-detail JSP with a bar chart, perform the following steps:

1.

From the View menu open the following JDeveloper windows if not already open: Data Control Palette, Property Inspector, Structure window, Component Palette.

Move your mouse over this icon to see the image

Note: Optionally, to save some space in the editor, you can drag the Component Palette on top of the Data Control Palettel. You navigate between them using tabs at the bottom.

 

2.

Expand the ViewController node. Expand Web Content and WEB-INF then double-click the
struts-config.xml
entry to open it in the Code Editor. Click the Page Flow Diagram tab in the Code Editor to open the visual editor for the Struts controller.

Move your mouse over this icon to see the image

 

3.

In the Component Palette select Struts Page Flow in the drop-down list, then drag the Data Page icon Data Page icon to the empty Struts Page Flow Diagram.

Move your mouse over this icon to see the image

 

4.

Rename the data page: change /dataPage1 to /deptemp.

Move your mouse over this icon to see the image

 

5.

To create a JSP page, double-click the /deptemp icon. Accept the suggested JSP page name /deptemp.jsp and click OK.

Move your mouse over this icon to see the image

 

6.

The visual JSP editor opens automatically for you to create the application's view.

Type JSP Graph Example into the page, highlight the words with the mouse, and select Heading 1 from the Block Format drop-down list at the top of the page editor.

Move your mouse over this icon to see the image

Press [Enter] to insert a blank line.

Move your mouse over this icon to see the image

 

7.

In the Component Palette, select CSS in the drop-down list. From the stylesheets shown, click Blaf.

Move your mouse over this icon to see the image

Note that the appearance of the JSP changes to the new look and feel.

 

8.

Navigate to the Data Control Palette that shows the entries of the model created earlier (if it doesn't, use the right mouse context menu to refresh the Data Control Palette.)

Select DepartmentsView1 and select Read-Only Form from the Drag and Drop As drop-down list. Drag DepartmentsView1 to the deptemp.jsp page to a location below the title.

Move your mouse over this icon to see the image

 

9.

In the Data Control palette, again select DepartmentsView1, but this time select Navigation Buttons from the Drag and Drop As drop-down list.

Drag the Navigation Buttons into the form frame at the end of the existing table on the JSP page. This automatically adds the navigation bar to the form tag of the DepartmentsView1 Read Only Form.

Move your mouse over this icon to see the image

 

10.

Expand the DepartmentsView1 node in the Data Control Palette. Select the EmployeesView3 entry and choose Graph in the Drag and Drop As drop-down list.

Drag the EmployeesView3 to the deptemp.jsp page to a location below the DeptEmpView1 Read Only Form.

Move your mouse over this icon to see the image

 

Step 3 - Customizing the Graph Component

Back to Topic List

The Graph component needs to be customized to show employee salary data only. To customize the graph, perform the following steps:

1.

In the Application Navigator, expand the ViewController node, then Application Sources, then view. Select the deptempUIModel.xml entry.

Move your mouse over this icon to see the image

 

2.

In the Structure window right-click the EmployeesView3 entry at the end of the list and select Edit... from the context menu.

Move your mouse over this icon to see the image

 

3.

On the Select Data Collection dialog page click Next because EmployeesView3 is already selected.

Move your mouse over this icon to see the image

 

4.

In the Select Attributes dialog select LastName from the Series Attributes drop-down list. In the Data Attributes list box, select Salary, then click Finish.

Move your mouse over this icon to see the image

 

Step 4 - Running the Application

Back to Topic List

Next you run the application to test that it functions properly. To run the JSP, perform the following steps:

1.

Select the struts-config.xml tab at the top of the editor window to open the Struts Page Flow editor.

Move your mouse over this icon to see the image

 

2.

Right-click the /deptemp icon and from the context menu select Run to run the application

Move your mouse over this icon to see the image

 

3.

The application should display the departments:

Move your mouse over this icon to see the image

The salaries of the employees in the displayed department are presented in a bar graph:

Move your mouse over this icon to see the image

 

Step 5 - Changing the Graph Component

Back to Topic List

You can change the type of graph that is displayed. To change the graph type, perform the following steps:

1.

To invoke a WYSIWYG graph editor, in the Application Navigator expand ViewController > Application Sources > view, then double-click he BIGraphDef1.xml file..

Move your mouse over this icon to see the image

 

2.

In the Graph Editor, click the Graph Type button Graph Type button at the upper left of the editor.

.Move your mouse over this icon to see the image

 

3.

Select Pie as the Graph Type and click OK.

Move your mouse over this icon to see the image

 

4.

You can run the application again to see the effects of the change.

Move your mouse over this icon to see the image

 

In this lesson you accomplished the following:

Used ADF Business Components to create a business service
Created a Struts Page Flow Diagram with a data page
Created a JSP with data from the business service

Added a data-bound graph to the JSP

Modified the graph to show only the employee salary labeled with the last name
Ran the application to test it

Changed the graph from a bar chart to a pie chart

For additional information, documentation, and demos, see the JDeveloper Products page on OTN.

Move your mouse over this icon to hide all screenshots

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy