ObjectExtender User's Guide and Reference

Creating a new top-level transaction each time one is committed

A top-level transaction is created by sending the following message:

     Transaction begin
 
 

The top-level transaction is a special transaction that is a child of the shared transaction. It can also be created with the method:

     Transaction shared beginChild
 
 

The TopLevelTransaction part, used in our example, will always create a fresh top-level transaction when the view is opened. To generate new top-level transactions each time one is committed, we will use a variable part for TopLevelTransaction rather than a non-variable part and use the SharedTransaction to create new top-level transactions as required. Visually, one can always reference the SharedTransaction on a Composition Editor with the SharedTransaction part. This part is always the same instance of the singleton shared transaction, even if it is used on many different views. This behavior can be contrasted with the TopLevelTransaction part that always generates a new top-level transaction each time the view is opened.

For this reason, we will change the TopLevelTransaction part in our example to a variable part. Changing the part to a variable part will give us more control over when to create the transaction that will be used inside the variable.

There are two situations when we need to create a top-level transaction: (1) when the view first opens, and (2) each time a commit happens.

Do the following:

  1. From the ObjectExtender parts palette category, drop a SharedTransaction part onto the free-form surface.
  2. Drop a variable part for TopLevelTransaction onto the free-form surface. This will replace the TopLevelTransaction part.
  3. Reconnect the TopLevelTransaction part connections to the TopLevelTransaction variable part, then delete the original TopLevelTransaction part.
  4. Connect the openedWidget event of the Window part to the beginChild action of the SharedTransaction and the result of this to the self attribute of the TopLevelTransaction variable.

    This ensures that when the view opens we have a top-level transaction to work with.

  5. Connect the committed event of the TopLevelTransaction variable to the beginChild action of the SharedTransaction part.

    This connection will generate a fresh top-level transaction each time one is saved.Connect the result of the connection to the self attribute of the TopLevelTransaction variable.

There are two conections from the commited event of the TopLevelTransaction variable. One of these is to the SharedTransation part to regenerate a fresh transaction and the other is to the items attribute of the List part to ensure that is refreshed. It is important to ensure that the connection to the SharedTransaction part is the first of these two that happens.

  1. Select the TopLevelTransaction part and from its pop-up menu, choose Reorder Connection From.
  2. Drag the connections to make sure that the connections fire in the right order.

You can also use a Business Transaction in place of the Top-Level Transaction.


Figure pgs1newt not displayed.

Note:When using ObjectExtender with Web Connection parts you must be particularly aware of transaction scope. When possible, the scope of the transaction should be limited to the equivalent of one page. If this design does not fit your application, then you will need to place a handle to the current transaction in session data. Each Web Connection part will then need to retrieve the current transaction from the session data. This is best accomplished by writing scripts.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]