Search This Blog

Saturday, March 19, 2016

12. OAF Displaying Data From Data Base

Displaying Data From Data Base



In this lesson we are going to see how to display a data from the data base in OAF.
 
Follow the steps to display the data in OAF page from the Data Base:
  1. Create the page.
  2. Create the VO in respective BC4J and attach it to AM.
  3. Create the controller and write the logicode in Process Form Request.

To create a VO right Click on the Resources Folder of the project and then select New View Object…
To see all the steps that how to create the VO we can see in previous chapter.
 
Write the following Query statement in VO
[sql]SELECT * FROM mtl_system_items_b WHERE  ROWNUM < 101[/sql] After creating VO attach VO to AM (Application Module). Now select main page right click on the main region select New -> Region Using Wizard...   Region using wizard in OAF
 
After selecting Region Using Wizard then a welcome window will get open as shown below:
 
Region using wizard
 
Click on Next button to see the first step:
 
Selecting AM in OAF
 
After selecting proper AM we can see the VO attached to that AM in the Available View Usages, which is shown below:
 
Selecting VO  for a region OAF
 
Click on Next button, in Step2 window select Region Style as “table”, the same scenario is shown in the below figure:
 
Region Style in OAF
 
In the next window we will find all the available attributes and in that select the attributes whichever required to display.
 
Slelecting required  Attributes in VO OAF
 
Click on Next button then we will find a window in that we can change the prompt names if required and also the style of the item we can change here we are taking all the items as Message Text input types.
 
Customize attribute prompts of VO in OAF
 
Click on Next button and then click on the finish button.
 
Finishing VO creation process in OAF
 
After creating Region Using Wizard now create one more item and the Item Style is “Submit Button”. So that the page structure looks like the following:
 
Page structure of OAF data display
 
Now create one controller on the main region. Right click on the region1(Main region id) and then select Set New Controller…
Now after creating the controller write the following code in the process Form Request.
 
[sql]public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
  super.processFormRequest(pageContext, webBean);
  if(pageContext.getParameter(“item1”)!=null)
  {
   /* The below code line is used to initialize the application module */
     OAApplicationModule am=(OAApplicationModule)pageContext.getApplicationModule(webBean);
   /* The below code line is used to initialize VO*/
     OAViewObject vo=(OAViewObject)am.findViewObject(“ItemsVO1”);
   /* ItemsVO1 is the instance name in AM which is the original name of the VO */
     vo.executeQuery();
   }
}[/sql]
 
Rebuild the code, run the page and see the output:
 
Output of display in OAF
 
Click on the “Go” button so that it will display the records as shown below:
 
OAF data display from database

No comments:

Post a Comment