Sunday, May 05, 2013

Creating Bar Graph in OAF

Here is an example of how to create a Bar Graph in OAF. Graphs are created with the graphTable region style.

1) Create a new OA page:
Right click on project (xxcus) --> New --> Web Tier --> OA Components --> select 'Page' item. Click OK. (This will open a popup window)
          Name: BarGraphPG

2) Create a new view object (VO):
Right click --> New View Object (This will open a wizard having 7 steps).

Step 1
Name: GraphVO
Choose the radio button 'Read-only Access' (as we are not performing any DML operation). Click Next.

Step 2
Enter the below query in 'Query Statement':
    select ename, sal from employee

Step 3
Generate Impl class for the view object.

Keep defaults for step 4, 5, 6 & 7 and click Finish. Save All.

3) Create a new Application Module (AM):

Step 1
Name: BarGraphAM. Click Next.

Step 2
Here we will add an instance of the VO created in (2). Select GraphVO from 'Available View Objects' and shuttle it to 'Data Model' using ">" button.
Keep defaults for all other steps (3, 4). Click Finish.

4) Create a new Controller (CO):
Right click on pageLayout region and create a new controller
Name: BarGraphCO

5) Creating the Page Layout & Setting its Properties
1) Create a new region under pageLayout of type graphTable. This will automatically create a default graphs container. Also, it will add a graph to the graphs container along with two default graphData columns.

Now change the properties for each field from property inspector as shown below:

     ID: pageLayoutRN
     AM Definition:
     Window Title: Employee Salary Graph Page
     Title: Employee Salary Graph

ID: graphTableRN
Graph render style: graph

set these properties for the graph:
ID: empSalGraph
Graph Type: vertical clustered bar
Title: Employee Name vs Salary
Size: Medium
X-axis label: Employee Name
set properties for graphData1:
ID: xAxisData
View Instance: GraphVO1
View Attribute: Ename
Purpose in Graph: groupLabels (it represents data on X-axis)

set properties for graphData1:
ID: yAxisData
View Instance: GraphVO1
View Attribute: Sal
Purpose in Graph: data (it represents data on Y axis)
Prompt: Salary

In PR method, we call a method of AM to intiate query:

public void processRequest(OAPageContext pageContext ,OAWebBean webBean){
   OAApplicationModule am = pageContext.getRootApplicationModule();

Code for initQuery method in file:

public void initQuery()
       GraphVOImpl graphVO=getGraphVO1();
     } catch(Exception ex){

Post a Comment