Skip Headers
Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers
10g Release 3 (10.1.3.0)

Part Number B25947-02
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

C ADF Equivalents of Common Oracle Forms Triggers

This appendix provides a quick summary of how basic tasks performed using the most common Oracle Forms triggers are accomplished using Oracle ADF.

This appendix contains the following sections:

C.1 Validation & Defaulting (Business Logic)

Table C-1 ADF Equivalents for Oracle Forms Validation and Defaulting Triggers

Forms Trigger ADF Equivalent

WHEN-VALIDATE-RECORD

Execute validation code at the record level

In the custom EntityImpl class for your entity object, write a public method returning boolean type with a method name like validateXXXX() and have it return true if the validation succeeds or false if the validation fails. Then, add a method validator for this validation method at the entity level on the "Validation" panel for your entity object. When doing that you can associate a validation failure message with the rule at that time.

WHEN-VALIDATE-ITEM

Execute validation code at the field level

In the custom EntityImpl class for your entity object, write a public method returning boolean type and accepting a single argument of the same datatype as your attribute, having a method name like validateXXXX(). Have it return true if the validation succeeds or false if the validation fails. Then, add a method validator for this validation method at the entity attribute level for the appropriate attribute on the "Validation" panel for your entity object. When doing that you can associate a validation failure message with the rule at that time.

WHEN-DATABASE-RECORD

Execute code when a row in the datablock is marked for INSERT or UPDATE

Override the addToTransactionManager() method of your entity object. Write code after calling the super.

WHEN-CREATE-RECORD

Execute code to populate complex default values when a new record in the data block is created, without changing the modification status of the record.

Override the create() method of your entity object and after calling super, use appropriate setAttrName() methods to set default values for attributes as necessary. To eagerly set a primary key attribute to the value of a sequence, construct an instance of the SequenceImpl helper class and call its getSequenceNumber() method to get the next sequence number. Assign this value to your primary key attribute. If you want to assign the sequence number lazily, but still without using a database trigger, you can use the technique above in an overridden prepareForDML() method in your entity object. If instead you want to assign the primary key from a sequence using your own BEFOREINSERTFOREACHROW database trigger, then use the special datatype called DBSequence for your primary key attribute instead of the regular Number type.

WHEN-REMOVE-RECORD

Execute code whenever a row is removed from the data block.

Override the remove() method of your entity object and write code either before or after calling super.


C.2 Query Processing

Table C-2 ADF Equivalents for Oracle Forms Query Processing Triggers

Forms Trigger ADF Equivalent

PRE-QUERY

Execute logic before executing a query in a Data Block, typically to setup values for query-by-example criteria in the "example record".

Override executeQueryForCollection() on your view object class and write code before calling the super.

ON-COUNT

Override default behavior to count the query hits for a Data Block

Override getQueryHitCount() in your view object and do something instead of calling the super.

POST-QUERY

Execute logic after retrieving each row from the datasource for a data block.

Generally instead of using a POST-QUERY style technique to fetch descriptions from other tables based on foreign key values in the current row, in ADF it's more efficient to build a view object that has multiple participating entity objects, joining in all the information you need in the query from the main table, as well as any auxiliary/lookup-value tables. This way, in a single round-trip to the database you get all the information you need. If you still need a per-fetched-row trigger like POST-QUERY, override the createInstanceFromResultSet() method in your view object class.

ON-LOCK

Override default behavior to attempt to acquire lock on the current row in the data block.

Override the lock() method in your entity object class and do something instead of calling the super.


C.3 Database Connection

Table C-3 ADF Equivalents for Oracle Forms Database Connection Triggers

Forms Trigger ADF Equivalent

POST-LOGON

Execute logic after logging onto the Database

Override afterConnect() on your custom application module. Since application module instances can stay connected while serving different logical client sessions, probably what you want is to override the prepareSession() which is fired after initial login, as well as after any time the application module is used by a user that was different from the one that used it last time.

PRE-LOGOUT

Execute logic before logging off from the Database

Override beforeDisconnect() on your custom application module class and write code.


C.4 Transaction "Post" Processing (Record Cache)

Table C-4 ADF Equivalents for Oracle Forms Transactional Triggers

Forms Trigger ADF Equivalent

PRE-COMMIT

Execute code before commencing processing of the changed rows in all data blocks in the transaction.

Override commit() method in a custom DBTransactionImpl class and write code before calling the super.

Note:

See this article for an overview of creating and using a custom DBTransaction implementation.

PRE-INSERT

Execute code before NEW row in the datablock is INSERTed into the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_INSERT then write code before calling the super.

ON-INSERT

Override default processing for INSERTing a NEW row into the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_INSERT then write code instead of calling the super.

POST-INSERT

Execute code after NEW row in the datablock is INSERTed into the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_INSERT then write code after calling the super.

PRE-DELETE

Execute code before row removed from the datablock is DELETEd from the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_DELETE then write code before calling the super.

ON-DELETE

Override default processing for DELETE-ing a row removed from the datablock from the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_DELETE then write code instead of calling the super.

POST-DELETE

Execute code after row removed from the datablock is DELETEd from the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_DELETE then write code after calling the super.

PRE-UPDATE

Execute code before row changed in the datablock is UPDATEd in the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_UPDATE then write code before calling the super.

ON-UPDATE

Override default processing for UPDATE-ing a row changed in the datablock from the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_UPDATE then write code instead of calling the super.

POST-UPDATE

Execute code after row changed in the datablock is UPDATEd in the database during "post" processing.

Override doDML() method in your entity class and if the operation equals DML_UPDATE then write code after calling the super.

POST-FORMS-COMMIT

Execute code after Forms has "posted" all necessary rows to the database, but before issuing the data COMMIT to end the transaction.

If you want a single block of code for the whole transaction, you can override the doCommit() method in a custom DBTransactionImpl object and write some code before calling super. To execute entity-specific code before commit for each affected entity in the transaction, override the beforeCommit() method on your entity object and write some code there.

POST-DATABASE-COMMIT

Execute code after database transaction has been committed.

Override commit() method in a custom DBTransactionImpl class and write code after calling the super.


C.5 Error Handling

Table C-5 ADF Equivalents for Oracle Forms Error Handling Triggers

Forms Trigger ADF Equivalent

ON-ERROR

Override default behavior for handling an error.

Install a custom error handler (DCErrorHandler) on the ADF BindingContext