Most of the ATG Commerce form handlers extend atg.commerce.order.purchase.PurchaseProcessFormHandler. This form handler, which is a subclass of atg.droplet.GenericFormHander, is an abstract class which implements a transaction management pattern that should be followed by any form handler that works with Order objects. This transaction management pattern is implemented through the form handler’s beforeSet, afterSet, and handler methods.
beforeSet Method
This method is called once before any form handler property is set or handler method is called. It implements the following transactional steps:
If the form handler’s
useLocksAroundTransactionsproperty istrue(the default), obtain a transaction lock before the transaction is created.This prevents a user from modifying an order in multiple concurrent threads. The lock name used defaults to the current profile ID. For more information, see
atg.commerce.util.TransactionLockFactory. (Note that use of locking has a small performance impact.)Check for an existing transaction and, if no transaction exists, create one.
Handler Methods
The handler methods implement the following transactions steps:
Synchronize on the
Orderobject.Execute logic for modifying the
Orderobject.For example, the
CartModifierFormHandlersubclass has ahandleAddItemToOrdermethod that executes the logic of adding an item to an order.Call the
OrderManagerobject’supdateOrdermethod to save the order data to the repository.End the synchronization.
afterSet Method
This method is called once after all form handler processing is completed. It implements the following transactional steps:
Commit or roll back any transaction that was created in the
beforeSetmethod.If the transaction was already in place before the
beforeSetmethod was called, theafterSetmethod does not end the transaction automatically; this is the application’s responsibility.If a transaction lock was acquired in the
beforeSetmethod, release the lock.
If you’re extending an ATG Commerce form handler and your code makes its own decisions about errors, you can mark a transaction for rollback by calling the setTransactionToRollbackOnly method.
For more information on PurchaseProcessFormHandler and its subclasses, you can examine the source files at <ATG9dir>\DCS\src\Java\atg\commerce\order\purchase and refer to the ATG API Reference.

