Home > Building Your Application > Displaying Items as Select ...
In this exercise, you edit fields (items) on the Create/Edit Employee page to display as select lists. Select lists are drop-down lists that contain lists of values that users can select to populate a field in the application. Displaying items as select lists consists of two general steps:
Create the list of values (LOVs) for each item.
Edit the item to display as a select list and reference the appropriate list of values you created.
Topics:
Next, you create lists of values for jobs, employees, and departments.
To create a list of values for jobs:
Click Application on the Developer toolbar (at the bottom of the page).
Click 4 - Create/Edit Employee.
Under Shared Components, Lists of Values, click the Create icon. The Create icon resembles a plus sign (+) that overlaps a small page.
The Create List of Values Wizard appears.
For Source, accept the default, From Scratch, and click Next.
For Name and Type:
Name - Enter JOBS
.
Type - Select Dynamic.
Click Next.
For Query or Static Values, replace the existing text with this:
SELECT job_title d, job_id v FROM oehr_jobs ORDER BY d
Note that the first column selected is the one displayed to the user (d), and the second is the value stored in or retrieved from the database (v).
Click Create List of Values.
Shared Components do not appear on this Page Definition until they are explicitly added to this page. You will do that later in this tutorial.
To create a list of values for employees:
Under Lists of Values, click the Create icon.
For Source, accept the default, From Scratch, and click Next.
For Name and Type:
Name - Enter EMPLOYEES
.
Type - Select Dynamic.
Click Next.
For Query or Static Values, replace the existing text with this:
SELECT first_name ||' '|| last_name d, employee_id v FROM oehr_employees ORDER BY last_name
Click Create List of Values.
To create a list of values for departments:
Under Lists of Values, click the Create icon.
For Source, accept the default, From Scratch, and click Next.
For Name and Type:
Name - Enter DEPARTMENTS
.
Type - Select Dynamic.
Click Next.
For Query or Static Values, replace the existing text with this:
SELECT department_name d, department_id v FROM oehr_departments ORDER BY d
Click Create List of Values.
After you create the lists of values, you need to edit these items so that they display as select lists. By default, the items display as text fields.
You also rename the P4_JOB_ID, P4_MANAGER_ID, and P4_DEPARTMENT_ID items.
To edit the job item:
Under Page Rendering, scroll down to the Items section.
Notice that the Items section lists all the items for this page. Currently all but two items show the default type of Text field.
Click P4_JOB_ID.
The Edit Page Item page appears.
Under Name, select Select List from Display As.
Under Label, change Label to Job
.
Scroll down to List of Values.
From Named LOV, select JOBS.
Click Apply Changes.
To edit the manager item:
Under Items, click P4_MANAGER_ID.
Under Name, select Select List from Display As.
Under Label, change Label to Manager
.
Under List of Values:
Named LOV - Select EMPLOYEES.
Display Null - Select Yes.
Null display value - Enter the following:
- No Manager Assigned -
Note that you did not include this information for Jobs because the Job column is mandatory. For optional columns, such as Manager and Department, you need to specify that the select list display a null record. You can also provide meaningful text to display to the user when this situation occurs.
Click Apply Changes.
To edit the department item:
Under Items, select P4_DEPARTMENT_ID.
Under Name, select Select List from Display As.
Under Label, change Label to Department
.
Under List of Values:
Named LOV - Select DEPARTMENTS.
Display Null - Select Yes.
Null display value - Enter the following:
- No Department Assigned -
Click Apply Changes.
Run the page.
In the form, note that the Job, Manager, and Department fields now display as select lists.