!--a11y-->
Golden
Rules for Validating and Non-Validating ActionsThere are some golden rules for when and how to use a validating action and when to use non-validating actions.
When to
Declare Validating Actions:· If an action event handler must rely on the fact that all user input is valid, the action should be declared as a validating action.
· If the end user can easily reproduce the UI element event that triggered the action, a validating event can be used in many cases. Examples are the UI element events IWDButton.onAction or IWDLinkToAction.onAction.
When to
Declare Non-Validating Actions:
· If an action like Cancel, Reset, or Reinitialize is to be performed, a non-validating action can be used in most cases.
· If an action event handler must rely on the fact that it is always executed, regardless of the validation state of the data entered, a non-validating action must be declared.
· If an action event handler is intended to react to status changes triggered by the UI – like changing the state of a radio button, check box, lead selection – a non-validating action should be used, since the corresponding event is only raised once when the end user changes the status. If the action event handler is not executed because of invalid data, the corresponding change event is not resent after the invalid data is corrected.
· If the end user would need to produce several events in order to trigger the same action in the same status in the case of invalid data, a non-validating action can be used in most cases. The IWDRadioButton.onSelect event is a good example. Imagine a validation error when selecting a different radio button as described above. The end user then needs to correct the invalid data, select another radio button, and finally select the desired radio button.
Implementing
Non-Validating Action Event Handlers:
· If a non-validating action event handler processes context data, it should check whether this data is valid and behave accordingly.
· If a non-validating action event handler disables UI elements or navigates to other views, it must take pending validation errors into account. It may easily happen that the UI element needed for correcting the validation error is no longer visible or enabled. In such a case, the non-validation action event handler must restore the relevant context attribute to a meaningful value. Otherwise, any subsequent validating actions are blocked by these validation errors and the end user has no means of error correction.