ObjectExtender User's Guide and Reference


Visual programming for more than one transaction

The TstDepartmentView built earlier uses only one transaction. This is the top-level transaction that it creates when it opens and regenerates each time it is committed. There is no guarantee however that this top-level transaction is the current transaction in a more complex scenario. Run the TstDepartmentView and create and edit some departments. Then switch to the System transcript ( without closing the TstDepartmentView) and make the shared transaction the current transaction with the following code:

     Transaction shared resume 
 
 

Switch back to the open instance of TstDepartmentView and try to create or edit some department. You will get a walkback telling you that are trying to create or modify objects in the shared transaction. This is because we explicitly switched the shared transaction to be the current transaction. Access to both the TstDepartmentHome part and the TstDepartment1 variable are done in the context of the current transaction and, because the shared transaction is read-only, the view will not work properly.

One way to program around this is to make the top-level transaction resume when the TstDepartmentView receives focus. This can be done with a connection from the gettingFocus event of the window to the resume action of the TstDepartment1 variable.

The problem with relying on the gettingFocus event is that it assumes that all work done on the TstDepartmentView is while it has focus. In more advanced scenarios it is possible that the view will ask questions of its objects without focus being received, for example to repaint or refresh an area of the screen following an expose event. It is also possible that more than one transaction can be going on together on the same view. The solution to this is to have a mechanism of specifying at design time an association between a part and a transaction and having the guarantee that all access to the part is done within the context of that transaction. This is provided for with the part TransactedVariable. This can be found on the palette, under the ObjectExtender category.


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