Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 4 Advanced Tasks : Using Enumerations as Choices in an Optionlist or Radiogroup

Using Enumerations as Choices in an Optionlist or Radiogroup
This section illustrates the use of enumerations in a business object model and associated forms.
Task
Specify choices for optionlists or radiogroups in the form with enumerations defined in the business object model.
Sample Project
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 form for this task (CapturePreferences.form) is at the following location:
   forms.samples.bom/Forms/BOMHowTo/BOMHowToProcess/
      CapturePreferences/
The business object model (FormsSamplesBOM.bom) is at the following location:
   forms.samples.bom/Business Objects/
You can double-click the form and business object model filenames (as well as those of other project resources) in the Project Explorer to open them in the editor. There, you can examine their contents and use them as models for your own projects.
Explanation
The business object model in the forms.sample.bom project models a Person class, a Preferences class, and three enumerations, Gender, Colour, and Beverage. There is a unidirectional composition association Person::preferences : Preferences[0..1]. (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.)
The CapturePreferences form shows a Person, his or her personal details, and preferences.
The Gender radiogroup choices are defined by the Person::gender : Gender[1] BOM feature, and the control is flagged as required to reflect the non-optional multiplicity of the feature. In the Properties tab of the Properties view, you can see the external reference to the Gender enumeration and the choice labels and values implied by that enumeration's literals. Note how the enumeration literals' labels and values in the business object model are automatically reused in the form.
The Favourite Colour optionlist is bound to the corresponding Preferences::favouriteColour : Colour[1] feature. As above, the feature is mandatory and the control is flagged as required. The choices are defined by the literals of the Colour enumeration.
The Favourite Drink optionlist is bound to the corresponding Preferences::favouriteDrink : Beverage[0..1] feature. Again, choice labels and values come from the BOM. This time, however, the feature is optional and the control is not flagged as required. Note that the Properties tab shows an additional choice (unset); this is only generated for a control that is not required.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved