15.4. Method parameters

Table 15.1. Parameters available in methods of DbEventInterceptor

Parameter Description
Connection cona database connection => this object makes it easy to "trigger" other functionality like database-logging, keep up special data constraints, execute a sub-query, etc.
DbFormsConfig config a config object provides the method DbFormsConfig.getServletContext() which gives access to other J2EE-resources which may be stored in application scope. This could be an entry point to any other application, including EJB-Apps, Struts-Apps, Messaging systems, etc.
HttpServletRequest request an http-request object gives access to various types of information, including the current user’s name and user’s groups/roles.
FieldValues fieldValues:

in the preInsert(), preUpdate() and preDelete()-methods: FieldValues which gives access to the fields contained in the current (selected) row.

(String) fieldValues.get("lastname").getFieldValueAsObject();

-or-

fieldValues.get("lastname").getFieldValue();

will return the field value of the field “lastName” of the row DbForm's is about to insert, to update or to delete. Note: ...getFieldValue(); always returns a String.

To make changes in preInsert() and preUpdate() so that changes in the FieldValues are reflected in the database, use setValue(Table table, FieldValues fieldValues, String fieldName, String value) as shown below:

this.setValue(table, fieldValues, "lastname", "smith");

will ensure that the value “smith” be stored in the lastname field in the database. (column lastname must exist!)

DbEventInterceptorData data

the DbEventInterceptorData contains the same data as the above parameters and can be accessed by using:

  • data.getConnection()

  • data.getConfig()

  • data.getRequest()

  • data.getTable()

  • (FieldValues) data.getAttribute(DbEventInterceptorData.FIELDVALUES)