ObjectExtender User's Guide and Reference

Editing departments

To make the list editable is the next goal. To edit the details of a department, you will select the department in the list and modify its data in text fields.

Do the following:

  1. Add a Variable part. You can use Object Extender visual parts on the parts palette or select Add Part from the Options menu, and type the class name, TstDepartment. Select Variable, under Part Type. Select OK.
  2. Connect the self attribute of TstDepartment to the selectedItem attribute of the List part.

    The variable will contain the object that represents the selected department as individual departments from the list are selected. By connecting the attributes of the department to some edit controls we can modify the details for a selected department.

    If we were to do these steps an exception would be raised by the shared transaction stating that we attempted to write into a read-only version. This is because persisted objects cannot be modified unless a transaction has been started.

ObjectExtender has some visual parts to help you work with transactions. In the Composition Editor, the parts palette has a category named | department | Transaction begin. department := TstDepartmentHome singleton findByDepartment: 'Math'. department markRemoved. Transaction current commit. . The first ObjectExtender part to illustrate is the TopLevelTransaction part. This part will always begin a new top-level transaction when the view on which it is used is opened.

Do the following:

  1. Add a TopLevelTransaction part on the free-form surface of the Composition Editor.
  2. Add a Push Button part to the Window part.
  3. Label the push button: Save.
  4. Connect the push button's clicked event to the commit action of the TopLevelTransaction part.
  5. Add two text boxes from the Data Entry controls and add corresponding labels for Building and Room. You can also use the Quick Form menu item and select the building and room attributes.
  6. Test the view by opening it and selecting the Math department.
  7. Change its building and room and then close the view.
  8. Open the view again.

    Note that the changes were lost. This is because the transaction was not committed.

  9. Make some changes again and click Save.

    This time the changes are committed to the shared transaction and made persistent.

Open it again and note that the changes were lost. This is because the transaction was not committed. Make some changes again and click Save. This time the changes are committed to the shared transaction and made persistent.


Figure pgs1topl not displayed.


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