The first screen that we will build will allow staff to be maintained. This will be a list screen and a separate screen to add and edit the staff. The first screen to build is the edit screen. For this create a visual part named TstStaffEditView. Build the screen as described below.
Understanding the notation: Instructions in this section do not follow the format used thus far. Instead, the following devices are used:
The numbers indicate the following:
Parts List | ||
Part Index | Part Class | Part Name |
1 | AbtLabelView | Label1 |
2 | AbtShellView | Window |
3 | AbtLabelView | Label2 |
4 | AbtTextView | Text1 |
5 | AbtLabelView | Label3 |
6 | AbtTextView | Text2 |
7 | AbtPushButtonView | PushButton1 |
8 | AbtTextView | Text2 |
9 | AbtTransactedVariable | Staff1 |
10 | AbtPushButtonView | PushButton2 |
11 | AbtVariable | TopLevelTransaction1 |
Property Settings | ||
Part Index | Property | Value |
1 | Object | StaffId |
3 | Object | FirstName |
7 | Object | Cancel |
8 | Object | LastName |
9 | PartType | Staff |
10 | Object | OK |
11 | PartType | TopLevelTransaction |
Connections | |||
Source Index | Source Feature | Target Index | Target Feature |
9 | staffId | 1 | object |
9 | firstName | 3 | object |
9 | lastName | 8 | object |
9 | isNotPersisted | 3 | enabled |
11 | self | 9 | transaction |
7 | clicked | 2 | closeWidget |
10 | clicked | 3 | commit |
10 | clicked | 2 | closeWidget |
2 | closedWidget | 11 | rollback |
Comments: Promote the self feature of the TopLevelTransaction1 variable and also the self feature of the Staff1 transacted variable. When this view is launched it can be passed a Staff object and a top level transaction and it will allow the staffId, firstName and lastName of the Staff object to be shown and modified. The OK button commits the transaction and shuts the view down, and the cancel button shuts the view down. When the view has been closed the transaction is rolledback as it is no longer required. It is important that the two connections from the OK button are in the correct order, that is, the transaction is committed and then the view closed. If they were the other way around the view would close itself and rollback the transaction before it was committed and the changes would be lost.
The next view that should be build is the one that will allow the existing staff to be listed and new ones to be added and edited. Create a visual part called TstStaffMaintenanceView and build it as follows:
Parts List | ||
Part Index | Parts List | Part Name |
1 | AbtListView | List1 |
2 | AbtShellView | Window |
3 | AbtPushButtonView | PushButton2 |
4 | AbtPushButtonView | PushButton1 |
5 | StaffHome (HomeCollection) | StaffHome1 |
6 | AbtAppBldrViewWrapperEditPart | TstStaffEditView |
7 | AbtTransactedVariable | transacted StaffHome1 (see comments) |
8 | SharedTransaction | SharedTransaction1 |
9 | AbtVariable | TopLevelTransaction1 |
The transacted variable (7) is created by clicking on the StaffHome to
bring up its pop-up menu an selecting Create Transacted
Variable.
Property Settings | ||
Part Index | Property | Value |
3 | Object | Edit |
4 | Object | New |
5 | PartType | StaffHome |
6 | PartType | TstStaffEditView |
7 | See comments section | |
8 | PartType | SharedTransaction |
9 | PartType | TopLevelTransaction |
Comments: As mentioned in the comments above, this part is
generated automatically.
Connections | |||
Source Index | Source Feature | Target Index | Target Feature |
5 | allInstances | 1 | items |
5 | self | 7 | self (see comments) |
4 | clicked | 8 | beginChild |
4 | clicked | 6 | openWidget |
4 | clicked | 7 | create |
3 | clicked | 8 | beginChild |
3 | clicked | 6 | openWidget |
3 | clicked | 6 | staff1 |
9 | self | 7 | transaction |
Comments: In the above connections: