Selector Widget and Enumerations

 

Learn how the selector widget works and how to use them with enumerations.

When you run XX_EMPLOYEE_DROPDOWN, you will see that the column “Number” has a drop down list. This is the default widget for enumerations and is known as the “selector” widget. When you click on one of the drop down lists, you will see the values of the enumerations defined in the XML. The widget is defined using fox:widget=”selector”.
Other widgets include

If you define an element of type xs:boolean, this is an implicit enumeration, with default values of fox:key-true=”Yes” and fox:key-false=”No”. It is possible to override these values by defining the attribute yourself. It is often necessary to override a key-true on tickbox booleans, e.g. fox:key-true=”Credit Check Completed”.

CONCEPTS

Mandatory enumerations are defined using the attribute fox:mand=”.” on an element.

If an element is mandatory, the default value of the selector is fox:key-missing=”Select One”. This can be over-ridden.

If an element is optional, the default value of the selector is fox:key-null=”None”. This is can be over-ridden.

An asterisk before the prompt denotes mandatory elements. Even if a field is mandatory, it can still be left blank unless validation is used as well. This is explained in a later chapter.

EXAMPLES

  1. Simple mandatory enumeration

<xs:element name=”EMPLOYMENT_TYPE” emp-list:edit=”.” fox:mand=”.”>
 <xs:simpleType>
  <xs:restriction base=”xs:string”>
    <xs:maxLength value=”20”/>
    <xs:enumeration value=”Contractor”/>
    <xs:enumeration value=”Civil Servant”/>
    <xs:enumeration value=”Agency”/>
  </xs:restriction>
 </xs:simpleType>
</xs:element>

  1. Non-mandatory Boolean

<xs:element name=”HOME_WORKER” type=”xs:boolean” emp-list:edit=”.”/>

EXERCISES

Exercise 1

In XX_EMPLOYEE_DROPDOWN, under COMPANY_INFO add an element named “AUTHORISED” and make it a mandatory Boolean.

NB: You will need to init this element to display it.

Exercise 2

Change the NUMBER element to a tickbox widget.

Exercise 3

Change the NUMBER element to a radio widget.

Exercise 4

Change the NUMBER element back to a selector.
Override key-null on NUMBER to display “None Selected” instead of “None”.

Exercise 5

Make NUMBER mandatory, and override key-missing to display “Please Select One” instead of “Select One”.

Exercise 6

On AUTHORISED, override key-true to display “True” and key-false to display “False”.