Rich UI provides a way to implement the kind of form processing that is traditional in business software. The processing depends on the Rich UI controller, which is a definition that relates a single view—a widget—with a single model—a data field. For details on Rich UI controllers, see “Rich UI validation and formatting.”
You interact with a form manager by writing code or by using code that the Rich UI editor provides for you.
employeeForm FormManager { entries = [
new FormField { nameLabel="Name:", controller=nameController },
new FormField { nameLabel="Age:", controller=ageController },
new FormField { nameLabel="Salary:", controller=salaryController }
]};
employeeForm ValidatingForm { entries = [
new FormField { displayName="Name:", controller=nameController },
new FormField { displayName="Age:", controller=ageController },
new FormField { displayName="Salary:", controller=salaryController }
]};
When using a validating form, you specify only the displayName and controller values in a form field. The rest of the values are handled by the validating form itself.
In either case, you invoke functions that handle each of the form fields in turn; for example, to validate the form as a whole.
A form field is itself a data collection: a record of type FormField. The record is used differently for a form manager and for a validating form. The use of a single record type for both of those mechanisms means that you can easily switch between the two.
As suggested in the next table, you set the record fields that are appropriate for your use.
| Field in the record of type FormField | Field value | Context | Details |
|---|---|---|---|
| controller | Controller | Form manager or validating form | The controller is a definition that relates a view to a model. |
| displayName | String? | Validating form | The string is assigned to a field label that is provided for you by the validating form. The string is ignored if you are using a form manager. |
| errorLabel | TextLabel | Form manager | The text label named errorLabel is
the error field; it displays the error message, if any, that is output
during validation of a form field. The appearance of the error field
changes when an error occurs. If you are using a form manager, supply the text label when you declare the form field. However, if you are using a validating form, the text label is provided for you. |
| nameLabel | TextLabel | Form manager | The form-field label. The setting is ignored if you are using a validating form, which provides a label and assigns the displayName value to that label. |
| labelClass | String? | For use by Rich UI | A CSS class. Do not change this value, which
is used to change the form-field label to its original appearance
after an error is resolved. The class name is EglRuiTextLabel; and the same class name is used when an error occurs, with the addition of the following, secondary class: FormErrorLabel. |
When you work with a validating form, provide the controller and displayName values. When you work with a form manager, provide the controller and nameLabel values and, optionally, the errorLabel value.
The form-level functions invoke controller-specific functions. The order of the invocations is opposite to the order of the form fields in the entries array.
if (employeeForm.isValid())
employeeForm.commit();
end
The controller itself invokes a controller-specific validStateSetter function at the end of validation.
if (employeeForm.isValid())
if (myValidation())
employeeForm.commit();
end
end
Here are the form-level functions in alphabetical order:
The function has no parameters or return value.
The function has no parameters and returns a Boolean to indicate whether the validation succeeded for all form fields or not. The difference between this function and isValid() is that this function does not notify valid state change listeners.
The function has no parameters or return value.
The function has no parameters and returns a Boolean to indicate whether the validations succeeded or not; that is, whether all the controller-specific validate functions returned a null or blank.