Create Search Page in OAF


Creating Search Page in OAF:

Below is the page we are going to create using which you can search for an employee either by name or number or both.

Search1

Create EmpSummaryVO with below query
Step1: Right click on resources in application navigator and select New View Object
Specify package=trng2.oracle.apps.ak.emp.server
Name=EmpSummaryVO

Search2

Step2: skip next steps and in sql statement use below query
SELECT EmployeeEO.EMPLOYEE_ID,
EmployeeEO.FULL_NAME AS EMPLOYEE_NAME, EmployeeEO.EMAIL_ADDRESS AS EMPLOYEE_EMAIL, EmployeeEO1.EMPLOYEE_ID AS MANAGER_ID, EmployeeEO1.FULL_NAME AS MANAGER_NAME, EmployeeEO1.EMAIL_ADDRESS AS MANAGER_EMAIL, flkp.meaning AS POSITION_DISPLAY
FROM FWK_TBX_EMPLOYEES EmployeeEO,
FWK_TBX_EMPLOYEES EmployeeEO1,
FWK_TBX_LOOKUP_CODES_VL flkp
WHERE EmployeeEO.MANAGER_ID = EmployeeEO1.EMPLOYEE_ID (+)
and EmployeeEO.POSITION_CODE = flkp.lookup_code
and flkp.lookup_type = ‘FWK_TBX_POSITIONS’

Search3

Step3: Skip next steps and in step 8 uncheck Generate java file under EmpSummaryVOImpl and check Generate java file under EmpSummaryVORowImpl

Search4

Assign EmpSummaryVO to EmpAM (EmpAM created in earlier article Develop OAF page to Insert Employee data)
Right click on EmpAM and select Edit EmpAM

Search5

Move EmpSummaryVO from available view objects to right under data model

Search6

Create Page EmpSearchPG

Step1: Right click on “Resources” in Application Navigator and select New
Under Web Tier > OA Components select Page

Search7

Specify Name=EmpSearchPG and Package=trng2.oracle.apps.ak.emp.webui

Search8

Step2: Under EmpSearchPG, set properties of default pageLayout region1 properties as follows
ID=PageLayoutRN
Region Style=pageLayout
AM Definition=trng2.oracle.apps.ak.emp.server.EmpAM
Window Title=Search Employees
Title=Employees

Creating Result based search
In Result based search, user personalizable views panel, simple search and advanced search panel can be enabled automatically

Step3: Right click on PageLayoutRN and select New > Region. Set properties of this new region (region1) as below
ID=QueryRN
Region Style=query
Construction Mode=resultsBasedSearch
Include Simple Panel=true
Include Views Panel=true
Include Advanced Panel=true

Step4: Right click on QueryRN and select New > Region Using Wizard
Select Application Module trng2.oracle.apps.ak.emp.server.EmpAM and EmpSummaryVO1

Search9

Specify Region ID=ResultsTable and Region Style=table

Search10

Select required attributes EmployeeId, EmployeeName, ManagerName and PositionDisplay

Search11

Click finish and set below properties to specify on which attributes need enable search

1. For EmployeeId
Search Allowed = true (this property makes the attribute to search for)
Sort Allowed = ascending (this property allows to sort on the data of this column)
Initial Sort Sequence=first (this makes initial data to sort on this attribute)
Selective Search Criteria = true (this property enables OAF to validate atleast one attribute having this property is needed to input for search)
User Personalization = true (needed so the user can save a personalized view)

2. For EmployeeName
Search Allowed = true
Sort Allowed = ascending
Selective Search Criteria = true
User Personalization = true

3. For ManagerName
Search Allowed = true
Destination URI=mailto:{@ManagerEmail} (this is called spell and this makes manager name as a link which executes mailto command)

Creating Auto customization criteria
This will be used to manually design search attributes. For example for Employee Name search item, we need to implement LOV for selection. So result based query region will not allow to get LOVs so we need to use Auto Customization

Step3: You can continue with above process we did for result-based. I.e after creating QueryRN and ResultsTable. Change properties of QueryRN that created in above process as below
ID=QueryRN
Region Style=query
Construction Mode=autoCustomizationCriteria
Include Views Panel = false
Include Advanced Panel = false

Step4: Right click on QueryRN and select New>simpleSearchPanel
This will automatically creates query components header region (region2) and messageComponentLayout region (region1)

Search12

Step5: Select header region region2 and set properties as ID=SimpleSearchHdr and change Text property to Search
Select messageComponentLayout region region1 and set properties as ID=SimpleSearchRegion

Step6: Right click on SimpleSearchRegion and select messageTextInput and set properties as follows
ID=SearchEmpNum
Selective Search Criteria = true
Data type = NUMBER
Maximum length = 15
Prompt = Employee Number
Length = 15

Step7: Right click on SimpleSearchRegion and select messageLovInput and set properties as follows
ID=SearchEmpName
Data type = VARCHAR2
Maximum length = 240
Prompt = Employee Name
Length = 40
External LOV=/trng2/oracle/apps/ak/emp/lov/webui/MgrLovRN (which we created in earlier session)
Selective Search Criteria = true
Disable Validation=true (this is setting to true if user should allow to enter partial value for name instead of selecting from LOV)
7.1: Select lovMap1 under lovMappings and set below properties
LOV Region Item = EmployeeName
Return Item = SearchEmpName
Criteria Item = SearchEmpName

7.2: Right click on lovMappings in the structure panel and select New>lovMap and set its properties as below
LOV Region Item = EmployeeNumber
Return Item = SearchEmpNum
Criteria Item = SearchEmpNum