Code examples
In the following code, a separate page is defined for each of three types of banking account:
| savings private loan | (savings := UlcBox new) ulcName: 'savings'; add: (UlcLabel new label: 'Special Rates on Savings accounts'; yourself) horizontalAlignment: UlcWidgetConstants::UlcBoxLeftAlignment verticalAlignment: UlcWidgetConstants::UlcBoxTopAlignment. (private := UlcBox new) ulcName: 'private'; alignVerticalTop; alignHorizontalLeft; add: (UlcLabel new label: 'Private Account Charges'; yourself); add: (UlcField new ulcName: 'charges'; columns: 10; yourself). (loan := UlcHBox new rows: 2; yourself) ulcName: 'loan'; add: (UlcLabel new label: 'Number of Credits'; yourself); add: (UlcField new ulcName: 'numberOfCredits'; columns: 10; yourself) horizontalAlignment: UlcWidgetConstants::UlcBoxLeftAlignment verticalAlignment: UlcWidgetConstants::UlcBoxTopAlignment. UlcPageBook new add: savings; add: private; add: loan; yourself
The ulcName property of each box added to UlcPagebook can be passed in the #setPage: message to activate that particular page, as follows:
aPagebook setPage: 'private'
UlcPagebook can set the current page based on the value of a specified attribute. For example, suppose an application needs to support various address formats depending on the residency of a person. Each address format is defined as a page in UlcPagebook, with each page having as its name the country whose addresses it handles. When the country of residence is selected, the book automatically sets the correct current page. To define this interdependency, the form model of UlcPagebook must be set to the one holding the country attribute. In UlcPagebook, its form attribute-name is set to the form model's country-of-residence attribute name, as follows:
|person pageBook countries| person := Person new. countries := Array with: 'United States' with: 'Germany' with: 'Japan'. pageBook := UlcPageBook new formModel: person; formAttributeName: 'countryOfResidence'; add: (UlcHBox new ulcName: 'United States';...; yourself); add: (UlcHBox new ulcName: 'Germany'; ...; yourself); add: (UlcHBox new ulcName: 'Japan'; ...; yourself); yourself