![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |
To view the sample for this task, import the advanced sample projects as described in Import the Forms Advanced Samples. The sample forms and business object model for the task described in this section are contained in the forms.samples.bom sample project.The business object model (FormsSamplesBOM.bom) is at the following location:The business object model FormsSamplesBOM.bom models a Person class, an Address class, and three extensions thereof: CanadianAddress, UKAddress, and USAddress.There is a composition aggregation Person::address : Address[1]. There is also AddressBook class with a composition aggregation AddressBook::address : Address[*]. (There are also some other types in the business object model that are not used in the present task, but pertain to other advanced task examples that also use this business object model.)There are two forms to illustrate the use of subclasses, CapturePerson.form and DisplayAddressBook.form.This form shows an instance of a Person together with his or her address. The form contains a separate pane per Address class. The form configures itself dynamically to accommodate inbound address that are instances of Address or instances of a subclass thereof.
1. In the Form Designer, use Form > Properties view > Preview Data > Custom to select test data containing persons with a CanadianAddress, UKAddress, and USAddress, respectively, and observe the different results under the GWT Preview tab. Note how the form displays a Xx Address(person_xxAddress) pane containing the fields appropriate to the Address subclass in question, including fields inherited from the base class Address and additional fields defined in the subclass.
2. The Address Type optionlist provides a means to change the address type on the fly. In the Properties tab of the Properties view for this control, Custom Values are the fully qualified class names of all available address classes together with appropriate labels.Changing the selection of the Address Type optionlist fires the Change Address Type rule, which contains two actions.
3. The Change Address Type action determines whether the person's current address type matches the optionlist value. If it does not, it creates a new address and replaces the old address with the new one, preserving the values of inherited fields.
4. The Configure Address Panes action refreshes the user interface to match the address type in the model. It shows the pane appropriate to the address type and hides the others. It sets the value of the visible address pane to the address and the values of the invisible panes to null.
5. The Form Load rule fires when the form is loaded and initializes the value of the Address Type optionlist. This in turn fires the Change Address Type rule to configure the user interface to suit the initial address type.This form shows an instance of an AddressBook together with the addresses within it, using a master-detail configuration. The form contains a grid pane to display the fields inherited from the base Address class and the details pane contains a separate pane per Address class. As before, the form configures itself dynamically to accommodate inbound addresses that are instances of Address or instances of a subclass thereof.
1. In the Form Designer, use Form > Properties view > Preview Data > Custom to select the MixedAddressTypes test data, which include an Address, a CanadianAddress, a UKAddress, and a USAddress.Observe the results under the GWT Preview tabs. Note how the form displays the address detail pane appropriate to the subclass of the currently selected row in the grid pane.Note also that this example uses an address pane pattern whereby the Address (addressBook_address) pane always provides the fields inherited from the base class Address and the subclass-specific Xx Address (addressBook_xxAddress) panes provide only the additional fields defined by the subclass. One could regard this as a UI inheritance pattern.
The address pane labels are not visible in the canvas, so use the Outline view to locate them.
2. The Address Master (addressBook_address__master) grid pane provides a means to create a new address of a user-selected class.
3. The Change Address Selection rule is triggered by a change in the grid pane selection. It contains a Configure Address Panes action much like the previous example.
![]() |
Copyright © TIBCO Software Inc. All Rights Reserved |