of an employee with any job other than
salesman. In the form, you can see that
the Comm field is disabled. To enable the
Comm field, change the Job field’s value
to SALESMAN.
DEFINING AN ADVANCED DYNAMIC
AC TION
Now modify the Employee application to
retrieve a department’s location as soon as
the Department field is updated. The application will use Ajax to retrieve the value
asynchronously without needing to submit
the entire page to the server.
To create the advanced dynamic action,
follow these steps:
Click the
1. Edit Page 2 button at the
bottom of the form page.
Right-click
2. Items and select Create Page
Item, as shown in Figure 1.
Select
3. Display Only, enter P2_LOCATION
for Item Name, click Next, click Next, click
Next, and click Create Item.
Right-click
4. P2_DEPTNO, and select
Create Dynamic Action.
Select
5. Advanced, enter Get Department
Location for Name, and click Next.
As you can see in Figure 2, you can
choose among many types of events
when you implement an advanced
dynamic action. Select Change (the
default). Leave the Condition field value
as - No Condition -, because you want the
change event to always fire.
Click
6. Next, and select Component -> Set
Value for Action.
In the
7. Settings region, which now
appears, select SQL Statement for Set
Type.
For
8. SQL Statement, enter select LOC
from DEPT where DEPTNO = :P2_
DEPTNO. For Page Items to Submit, enter
P2_DEPTNO. Click Next.
For
9. Selection Type, choose Item(s).
In the list of items that then appears,
Figure 2: Selecting the event type for a dynamic action
Figure 3: Change the department, see the result
double-click P2_LOCATION, and then
click Create.
Now when you run the application and
change the value for any employee’s department, you’ll see that the location is updated
immediately, as shown in Figure 3.
David Peake (david
. peake@oracle.com)
is a principal product
manager in Oracle’s
Server Technologies
division. He has been
with Oracle since 1993.
DOWNLOAD
Oracle Application Express
oracle.com/technetwork/developer-tools/apex/
downloads
Oracle Database 11g Release 2
oracle.com/technetwork/database/enterprise-edition/downloads
CONCLUSION
Dynamic actions in Oracle Application
Express 4.0 enable developers to meet the
demand for client-side functionality, where
the application responds as soon as a value is
changed or the user leaves a field. Dynamic
actions are designed to make implementing
such functionality declarative, which gives
developers the potential to rapidly incorporate rich Web 2.0 user interactivity into
their applications without writing any Ajax
scripting code. By defining client-side
behavior on declarative property pages, you
speed development, simplify debugging, and
reduce maintenance requirements.
NEXT STEPS
READ more Browser-Based
oracle.com/technetwork/issue-archive/index-
093536.html
LEARN more about Oracle Application
Express
oracle.com/technetwork/developer-tools/apex/
overview
REQUES T an Oracle Application Express 4.0
workspace
apex.oracle.com
VISIT the Oracle Application Express
discussion forum
forums.oracle.com/forums/
forum.jspa?forumID=137