Requirement: To filter Poplist/Dropdown list based on a condition or event in OAF
Consider that you have a huge list of employee names in a dropdown list and you would like to filter the dropdown list to consist of only those employee names which start with 'AA'. The menioned scenario can be easily implemented using poplist/picklist/dropdown filtering in OAF using the steps below. Happy coding!
Step 1: Create a new OA workspace and OA project
Create a OA workspace with file name as: Poplist
Create a OA project with file name as: Poplist
Default package: oaf.oracle.apps.fnd.poplist
Once your project is created, double click on Poplist 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 Poplist project -> click New -> select ADF Business components -> select Application Module
Package: oaf.oracle.apps.fnd.poplist.server
AM Name: PopListAM
Check Application Module Class: PopListAMImpl Generate Java File(s)
Step 3: Create a OA Components page
Right click on Poplist project -> click New -> select OA components under Web Tier -> select Page
Package: oaf.oracle.apps.fnd.poplist.webui
Page Name: PopListPG
Step 4: Set Page properties
Select on the PopListPG 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.poplist.webui
Controller name: PopListCO
Note: This automatically sets the controller class property in PopListPG page properties
We have created CO to capture a button event which will be created in some time - in which we set-where-clause on the PopListVO query to filter the Poplist values
Step 6: Create a ADF Business component - View Object
Right click on Poplist project -> click New -> select ADF Business components -> select View Object
Package: oaf.oracle.apps.fnd.poplist.server
VO Name: PopListVO
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 USER_NAME from FND_USER
Ensure attribute 'UserName'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 PopListAM -> Edit PopListAM
Select 'Data Model' on the window that pops up
You should find PopListVO listed in the left panel, Shuttle the PopListVO to the right pane to associate it with the PopListAM which is displayed as PopListVO1 as in the below screenshot
Click on Apply and OK to save the changes made to PopListAM
Step 8: Create Poplist or Dropdown list in PopListPG
Right click on PageLayoutRN -> New -> Item
Now, this creates a new item of style messageTextInput under PageLayoutRN
Select item1 and set the item style to messageChoice and set other properties in the properties window as in the below screenshot
In the properties window, setting the Picklist View Instance field is very important
- Not setting this field, our CO will fail to execute the where-clause that is set on the PopListVO
- Executing Query on VO ends up picking the default query in VO
- This executes the default query and the set-where-clause will not have any effect, if Picklist View Instance field is neglected
Step 9: Capture button click
Capture the button click event in CO and set where clause on the VO attached to your poplist which filters the poplist as per condition set.
Add the code in the following Process Form Request Function in your CO as in the below screenshot
Code:
if(pageContext.getParameter(“filterPopList”)!=null){
PopListAMImpl am = (PopListAMImpl)pageContext.getApplicationModule(webBean);
PopListVOImpl voimpl = (PopListVOImpl)am.findViewObject(“PopListVO1”);
voimpl.setWhereClause(“USER_NAME like ‘AA%’”);
voimpl.executeQuery();
}
Result:
On page load:
Comments
RSS feed for comments to this post