The handler methods in a form handler that manipulates repository items should ensure that all the operations that occur in a method call happen in a single transaction. If all the operations do not occur in the same transaction, there is the risk that incomplete data will be committed to the repository if something goes wrong before the operation is finished. Committing all the operations at once ensures that a repository or database transaction is either completed successfully, or not completed at all (in which case, any partially committed data is rolled back).

The RepositoryFormHandler, ProfileForm, and ProfileFormHandler classes all ensure “atomic” transactions in this way. If you subclass one of these classes without overriding the handler methods, your subclass will handle transactions properly. If you override any handler methods, or add new handler methods, make sure that they handle transactions appropriately as described here.

If you are writing a new form handler that works with repository items, you can avoid the need to add any transaction management code to your handler methods by subclassing the TransactionalFormHandler. In this class, the transaction management occurs in the beforeSet and afterSet methods. This behavior establishes the transaction before any of your properties are set or handler methods are called, rather than in the handler methods themselves. For an example of transaction management within a handler method, see the source code in the ATG distribution at <ATG10dir>/DPS/src/Java/atg/userprofiling/.