Consider that you have a huge table on a page and you would like to add a scrollbar the table itself instead of sticking the usual page scrollbar. Below steps explain you the way to add scrollbars to a given region in OAF.
Requirement: To add scrollbars in OAF
Step 1: Create a new OA workspace and OA project
Create a OA workspace with file name as: ScrollBar
Create a OA project with file name as: ScrollBar
Default package: oaf.oracle.apps.fnd.scroll
Once your project is created, double click on ScrollBar project and select Project content.
Click on 'Add' button next to the bottom pane in the Project content and select only that package which you want have in your project.
Click OK and save your project.
Step 2: Create a ADF Business component - Application Module AM
Right click on ScrollBar project -> click New -> select ADF Business components -> select Application Module
Package: oaf.oracle.apps.fnd.scroll.server
AM Name: ScrollAM
Check Application Module Class: ScrollAMImpl Generate Java File(s)
Step 3: Create a OA Components page
Right click on ScrollBar project -> click New -> select OA components under Web Tier -> select Page
Package: oaf.oracle.apps.fnd.scroll.webui
Page Name: ScrollPG
Step 4: Set Page properties
Select on the ScrollPG page and go to structure pane where a region of type 'pageLayout' and ID 'region1' is automatically created.
Click on region1 in structure page and set the project properties as in the below screenshot - set all the properties except the controller class, for now.
Step 5: Set new Controller
Select PageLayoutRN in the structure pane -> Right click on it -> Set new controller
Package: oaf.oracle.apps.fnd.scroll.webui
Controller name: ScrollCO
This automatically sets the controller class property in ScrollPG page properties
Step 6: Create a ADF Business component - View Object
Right click on ScrollBar project -> click New -> select ADF Business components -> select View Object
Package: oaf.oracle.apps.fnd.scroll.server
VO Name: ScrollVO
Keep click 'Next' until you land at step-5(SQL Statement) of VO creation.
Paste the following SQL statement in the 'Query Statement' block as in the below screenshot:
SELECT employee_number, full_name, national_identifier, email_address FROM per_all_people_f
Ensure all the above mentioned column names comes up in the attributes step in VO creation.
In step-8(Java) of VO creation uncheck all the pre-selected checkboxes and select View Row Class: ViewObjRowImpl -> Generate Java File -> Accessors check box Accept all other defaults in VO creation, click Finish to create the VO under the package specified.
Step 7: Attach VO to AM
After creating VO successfully, we must associate this VO with AM we have created
Right click on ScrollAM -> Edit ScrollAM
Select 'Data Model' on the window that pops up
You should find ScrollVO listed in the left panel, Shuttle the ScrollVO to the right pane to associate it with the ScrollAM which is displayed as ScrollVO1 as in the below screenshot
Click on Apply and OK to save the changes made to ScrollAM
Step 8: Create a table in ScrollPG
Right click on PageLayoutRN -> New -> Region using Wizard..
-> In the wizard that comes up, Select ScrollAM from the applciation module dropdown list and ScrollVO from the available view usages pane
-> Click Next
-> Select region style as table
-> Shuttle all the attributes from the left to the right
-> Click next and set the properties as below in the custom properties step and finish table creation by accepting remaining default settings
Step 9: Adding scrollbar end points
Right click on PageLayoutRN -> New -> Item
Set item properties as follows:
Also, create one more item as above and set the properties as below:
Now the final page layout should look similar to the below one:
Step 10: Add scrollbar
Add the below code in PR to add scrollbars around the table created
try{
String l_height = "150";
String l_width = "400";
pageContext.putMetaTag("toHeight","<style type=\"text/css\">.toHeight {height:10px; color:black;}</style>");
OARawTextBean divStart = (OARawTextBean)webBean.findChildRecursive("divStart");
if(divStart == null){
throw new OAException("Not able to retrieve raw text bean just above the desciprtive element. Please verify the id of raw text bean.");
}
OARawTextBean divEnd = (OARawTextBean)webBean.findChildRecursive("divEnd");
if(divEnd == null){
throw new OAException("Not able to retrieve raw text bean just above the desciprtive element. Please verify the id of raw text bean.");
}
String divText = "";
divText = "<div style='height:" + l_height + "px; width:"+l_width+"px; overflow:auto; border:0;'>";
if(divText!="" && divText!=null){
divStart.setText(divText);
divEnd.setText("</div>");
}
ScrollAMImpl am = (ScrollAMImpl)pageContext.getApplicationModule(webBean);
OAViewObject vo = (OAViewObject)am.findViewObject("ScrollVO1");
vo.executeQuery();
} catch(Exception e){
System.out.println("Error in adding scrollbars::::"+e.getMessage());
e.printStackTrace();
}
Result:
On page load: