You are on page 1of 44

Creating and Running a Database Application Using Oracle Application

Express 4.0

This tutorial contains the following sections:

Purpose
Time to Complete
Prerequisites
Creating a Database Application
Editing Application Objects
Creating Lists of Values (LOVs)
Adding an Item Validation
Summary

Purpose
This tutorial shows you how to rapidly create a database application using Oracle Application Express.

Time to Complete
Approximately 80 minutes

Prerequisites
Before you perform this tutorial, you should:

1 . Perform the Manipulating Database Objects Using Application Express 4.0 tutorial.

Creating a Database Application


To create a database application with a few initial pages, perform the following steps:

1 . From the Oracle Application Express home page, click the down arrow next to Application Builder tab and select
Applications > Database Applications.

2 . Click Create.
3 . Select Database and click Next >.

4 . Select From Scratch and click Next >.

5 . For Name, enter Project Tasks Application. Keep the default value of From Scratch for the Create Application, and
click Next >.
6 . Enter Home for Page Name and click Add Page.

7 . You see the Master Detail page type. Master Detail builds a two page report and form combination. Select Master
Detail for Page Type. Select Home(1) for Subordinate to Page, OBE_PROJECTS for Master Table Name, and
OBE_TASKS for Detail Table Name. Click Add Page.
8 . The Master Detail pages were created, click Next.
9 . Accept the default and click Next.

10 . Accept the default and click Next.


11 . You can define a date format that will be used throughout your application. This date format will be used to alter the
NLS_DATE_FORMAT database session setting prior to showing or submitting any page within the application. This
format is used by all reports showing dates and is also picked up by form items of type 'Date Picker (use Application
Date Format)'.

Select an Application Date Format for your Application and click Next.

12 . Select Theme 1 and click Next.


13 . Click Create.

14 . Your application was created successfully. Click Run Application.


15 . Because you chose the default of Application Express Authentication, you need to login to the new application using
the same login you use to develop. Enter obe for the User Name and obe for the Password. Then click Login.

16 . Select Obe Projects.

17 . A report containing the list of projects is automatically created. Select the Edit ( )icon next to one of the projects

to view the Master detail Form.


18 . The Master Detail Form is shown. This page allows a user to edit the details of the Project as well as the details of
the Tasks associated with the Project. It also allows users to add new tasks to the current project.

In the master region, you can use the backward( )and forward ( )buttons to move to previous and
next projects. For example, if you have clicked the edit icon next to the Public Website project in the previous step,
you see a backward button here.

In the detail region, you see an Add Row button. This button saves any pending changes and then adds another
row so that a new task can be added to the project. You should also have a Delete Checked button. This button is
used in conjunction with the check boxes to the left of each Task. When you click the Delete Checked button, any
tasks that have been "checked" are deleted. If you use this feature, you notice that a deletion confirmation has been
built in. This asks you to confirm your deletion before proceeding.

Change the name of the project and click Apply Changes.

Editing Application Objects


Although the Master-Detail form is fully functional, the presentation can be improved. In this topic you change the names of
the Page Title, Region Title and change the format an item on the Master Report. Additionally, you print the Projects report in
the PDF format. Lastly, you change the sequence of items in the Projects and Tasks page using the Drag and Drop feature.
Perform the following steps:

1 . Select Edit Page 2.


2 . You see the Tree View of Page 2. In the Page Rendering section, under Regions node, locate and expand the Obe
Projects > Report Columns node. This displays the report columns.

3 . Right-click PROJECT_DEADLINE and select Edit.


4 . Under Column Attributes, enter DD-MON-YYYY for the Number/Date Format field and click Apply Changes.

5 . Click Apply Changes.


6 . In the Page Rendering section, right-click Obe Projects page title, and select Edit.

7 . In the Name section, enter Projects for the Name. In the Display Attributes section, enter Projects for the Title.
Then click Apply Changes.

8 . Click Run.
9 . Notice that the date format of the PROJECT_DEADLINE has changed. You notice that the Region title is still set to
OBE_Projects. Click Show Edit Links in the Developer links area.

10 . Click the Edit ( ) icon next to the Obe Projects Region title.

11 . Change the title to Projects and click Apply Changes.

12 . Click Cancel to close the Page Region window.


13 . Refresh your browser to show the change you just made. Click Hide Edit Links in the Developer Links.

14 . You can search projects by entering a key word in the Search text box. Enter email in the Search text box and click
Go.
15 . Observe that the associated row text is highlighted in red color. Click Reset. Then, click the Edit Page 2 link in the
developer tool bar.

16 . In the Page Rendering section, under Regions node, locate Projects. Right-click Projects and select Edit Print
Attributes.
17 . Select Yes in the Enable Report Printing drop-down menu and select Portrait in the Orientation drop-down menu
under Page Attributes. Then click the Page Header tab.
18 . Enter Project Report for Page Header and and set the Alignment to left. Click Apply Changes.

19 . Click Run.

20 . Notice the Print link at the bottom of the report. Click the Print link.

21 . Click the Open with radio button and click OK to view the report in PDF format.
Note: In order to use print services functionality, BI Publisher needs to be running. You see an error if the BI
Publisher is not running.

22 . The Projects report is displayed in the PDF format.

23 . Select the edit icon in front of the row for the Public Website project.
24 . If you move your mouse over Project, Project Deadline, or Project Priority item label, you see a ? symbol. If you click
any of these item labels, you see a help window. You can add edit text by editing the item. Close the Help window.

25 . Click Edit Page <n>.


26 . In the Page Rendering section, under Regions, double-click the PROJECT item.
27 . Select the Help Text subtab.

28 . Change the Help Text to something else and click Apply Changes.

29 . Click Run.

30 . Click the Project label again and notice that your help text is displayed.
31 . You can reorder the items on your page. Click Edit Page <n>.

32 . The page definition for Page 3 is displayed. To reorder the sequencing of items in this page, you can drag and drop
an item to a new location. Drag and drop the P3_PROJECT_ PRIORITY item above the P3_PROJECT_ DEADLINE
item and release your mouse.
33 . The item was moved. Click Run.

34 . Note how the Project Priority field now appears above the Project Deadline field. Click the Application <n> link in
the developer tool bar.
Creating Lists of Values (LOVs)
Another way to improve the presentation of the application is to create a List of Values. In this topic, you create the following
LOVs:

EMPLOYEES A Dynamic LOV to show the list of Employees. This LOV is then associated with the Assigned To column
in the List of Tasks.
STATUSES A Static LOV to show the list of Statuses. This LOV is then associated with the Status column in the List
of Tasks.
PRIORITIES A Static LOV to show the list of Priorities. This LOV is then associated with the Priority column in the
Projects Master area.

Perform the following steps:

1 . Click the 3 - Master Detail page.


2 . In the Shared Components column, right-click List of Values and select Create.

3 . For Create List of Values, keep the default value From Scratch, and click Next >.

4 . For Name, enter EMPLOYEES. For Type, change the type to Dynamic. Then click Next >.
5 . For a dynamic LOV, you need to enter the SQL you want to execute when the page is rendered. To find out what the
names of your columns are, you can select the item finder ( ) icon.

6 . Click the Tables tab.

7 . Select the OBE_EMPLOYEES table link.


8 . Note the names of the columns. Exit the Item Finder window.

9 . Enter the following SQL statement and click Create List of Values. The first column in a dynamic list of values is the
column displayed to the user. The second column is the corresponding value to be stored in the database. They can
both be the same value when appropriate.

select FIRST_NAME||', '||LAST_NAME d,


EMPLOYEE_ID r
from OBE_EMPLOYEES
order by 1

10 . Your LOV was created. Note that the List of Values does not appear like an expandable node because you haven't
yet associated it with this page. You want to create 2 more static LOVs. Right-click and select Create again.

11 . For Create List of Values, keep the default value From Scratch, and click Next >.
12 . Enter STATUSES for the Name and make sure Static is selected for the type and click Next >.

13 . For Display Value and Return Value, enter the following:

Display Value Return Value


Closed closed
Open open
On Hold on-hold

Click Create List of Values.

14 . The STATUSES LOV was created. There is one more LOV to create for the Master portion of the form, Priorities.
Click Create.

15 . For Create List of Values, keep the default value From Scratch, and click Next >.
16 . Enter PRIORITIES for the Name and make sure Static is selected for the type and click Next >.

17 . For Display Value and Return Value, enter the following:

Display Value Return Value


High 1
Medium 2
Low 3

Click Create List of Values.

18 . The PRIORITIES LOV was created. Now you can associate the LOVs with the page. Click the Edit Page 3 ( )
icon.
19 . In the Page Rendering section, under OBE_Tasks node, expand Report Columns.

20 . Then, right-click ASSIGNED_TO column and select Edit.


21 . Click the Column Attributes section button.

22 . Change the Display As to Select List (named LOV) and click the List of Values section button.
23 . Select EMPLOYEES for the Named LOV and click Apply Changes.

24 . Click the Edit ( ) icon in front of the STATUS column.

>

25 . The List of Values section button should be already selected. Select STATUSES for the Named LOV and click the
Column Attributes section button.
26 . Select Radio Group (named LOV) for the Display As and click Apply Changes. Click Apply Changes again.

27 . Note that List of Values now appears as an expandable node. Now you can run the page again to see the results.
Click Run.

28 . Select the dropdown list for Assigned To. You see that the dynamic LOV executed and the list of Employees is
shown.
29 . Note that the radiogroup is created for Status. You see that the static LOV values are shown.
30 . Next, you need to assign the the PRIORITIES LOV to the Priority item in the Master area of the page. Click Edit
Page 3 .

31 . Under Page Rendering, Items node, right-click P3_PROJECT_PRIORITY and select Edit.

32 . Select the Radio quick link under the Display As field or select Radio Group from the drop down list and click the
List of Values section button.

33 . Select PRIORITIES for the Named LOV, select Yes for Display Null Value, select No for Display Extra Values, and
enter None for the Null display value. Then click Apply Changes.
34 . Click Run.

35 . The Priority field is now a Radiogroup populated with the LOV values. Click Edit Page 3 in the Developer links.
Adding an Item Validation
You don't want a user entering a date prior to today's date. This type of check can be done through an item validation.
Perform the following steps:

1 . In the Page Processing section for Page 3, right-click Validations and select Create.
2 . Accept the default to create an Item level validation and click Next >.

3 . Select the item P3_PROJECT_DEADLINE and click Next >.


4 . Select SQL for the Validation Method and click Next >.

5 . Because you want to specify the condition when a PROJECT_DEADLINE is incorrect, click SQL Expression and
click Next >.
6 . Enter P3_PROJECT_DEADLINE greater than today as Validation Name and click Next >.

7 . Enter TO_DATE(:P3_PROJECT_DEADLINE,'DD-MM-YYYY') >= SYSDATE for the Validation and Date needs to
be greater than today for the Error Message and click Next >.
8 . Select Request Is Contained within Expression1 for the Condition Type and enter SAVE, CREATE for
Expression1. Then click Create.

9 . The validation has been created successfully. Click Run.


10 . Change the date to something prior to today's date and click Apply Changes.

11 . Notice that you receive an item (or field) error message as well as a page notification message. This is because you
specified that you wanted both when you created the validation.
12 . Click the Application <n> link in the developer tool bar.

Summary
In this tutorial, you have learned how to:

Create an application
Edit Application Objects
Create List of Values (LOVs)
Create and test a validation

About Oracle |Oracle and Sun | | Careers | Contact Us | Site Maps |


Legal Notices | Terms of Use | Your Privacy Rights

You might also like