Using Multiplicity to Configure Form Controls

Consider the Claimant and Witness classes in our business object model. Each of those classes is connected by composition to the GenericClaim class, meaning that claims can have claimants and witnesses.

Whether claims are required to have claimants or witnesses is determined by whether or not a multiplicity of zero is allowed for claimants or witnesses, as explained in the previous section of this tutorial. If the multiplicity is 0..1 (zero to one) or * (zero to many), the class’s attributes will be represented on the form by optional fields. If the multiplicity is 1 (one) or 1..* (one to many), zero is not allowed, and the class’s attributes will be represented on the form by required fields.

Multiplicity, then, determines whether or not fields on the form are required or optional. But multiplicity also has another important consequence: it determines whether the pane representing the class on the default form holds only a single element of that class or can hold multiple elements.

The Claimant class contains two attributes, name and address. The Witness class contains three attributes, name, address, and zip. Controls for the two Claimant attributes will appear grouped within a pane on the default form, as will the controls for the three Witness attributes. Each class has its own multiplicity value, defined as part of the composition that connects it to the GenericClaim class. The multiplicity setting applies to all of the attributes within that class.

There are two possible cases with respect to the multiplicity of a class:

  • When a class has a multiplicity of 1 or 0..1, there can be at most one element of the class, and thus one value at runtime for each of its attributes. In this case, a single text field for each attribute appears within the pane corresponding to that class on the default form.

    In this section of the tutorial, we will set the Claimant class to have a multiplicity of 1, meaning there can only be a single claimant for a claim. (The multiplicity setting of 1, rather than 0..1, also means that the fields for the claimant will be required.)

  • When a class has a multiplicity of * or 1..*, there can be many instances or elements of that type at runtime. Each element appears in a grid pane (a pane that contains multiple elements of a certain type) corresponding to that class on the form. Each element in the grid pane has a field corresponding to each attribute of the class.

    In this section of the tutorial, we will set the Witness class to have a multiplicity of *, meaning there can be multiple witnesses for a single claim. (The multiplicity setting of *, rather than 1..*, also means that, at runtime, a particular claim may have no witnesses.)

After setting the multiplicity values for the Claimant and Witness classes in the business object model, you will examine the default form to see the impact this change has on the panes and controls on the form.

Procedure

  1. Open the business object model in the editor pane, if it is not already open.
  2. In the diagram, select the 0..1 label near claimant. Change the value to 1 in the Multiplicity field in the General tab of the Properties view.
  3. In the diagram, select the 0..1 label near witness. Change the value to * (asterisk) in the Multiplicity field in the General tab of the Properties view.
  4. Save the business object model.
  5. Right-click the Record no-fault claim details user task and click Form > Preview.

    Notice that the Claimant class has been rendered as a vertical pane that contains a single element, while the Witness class has been rendered as a grid pane, which can hold multiple elements, each of which represents a single witness. The asterisks next to the Name and Address fields of the Claimant pane indicate that those fields are required.