Build Web 2.0 Applications DeclarativelyBy David Peake
Use dynamic actions in Oracle Application Express 4.0 to define interactive client-side behavior.
In this column, you’ll build an application that uses dynamic actions to implement Ajax behavior. You can run through these steps on the hosted instance of Oracle Application Express 4.0 at apex.oracle.com. (You must request a free workspace to use this hosted instance.) You can also use a local instance of Oracle Application Express 4.0. This exercise uses the EMP and DEPT tables, which are available by default in the database.
Creating the Demonstration ApplicationStart by creating a database application that enables users to view and edit employee data. Log in to Oracle Application Express and follow these steps to create the demonstration application:
Now enhance the form you’ve just generated to include select lists for job and department. The following steps and subsequent instructions assume that you are using the tree view, not the component view, in Application Builder:
Click Run and log in with your Oracle Application Express credentials to run the application. Navigate back to the report by clicking the first Emp link in the breadcrumbs. You can edit any record by clicking its Edit icon.
Defining a Standard Dynamic ActionNow create a dynamic action that will enable the form’s commission field (called Comm) only for employees whose job title is salesman. Follow these steps:
Run the application, and edit the record 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 ActionNow 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:
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.
Figure 3: Change the department, see the result
ConclusionDynamic 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.
David Peake (firstname.lastname@example.org) is a principal product manager in Oracle’s Server Technologies division. He has been with Oracle since 1993.
Send us your comments