The showError web trigger enables you to catch and report a server-side validation error for a field in the data layer of a dynamic server page.
|Applies to:||This trigger is applicable to all fields.|
|Activation:||Activated in the browser for each field in the data layer that fails validation on the server.|
|Default behavior:||Error class
|Behavior upon completion:||None|
The showError trigger can return undefined (no return value),
true, or no return value is defined—default error handling occurs. If there is a bound error element (such as
<span uflderror:FIELD.ENTITY.MODEL/>) present in the layout, it is assigned the error text and an error style class is applied. This is applied even if additional styling is defined in the trigger.
false, the default error handling is suppressed. Thus, if bound error elements are present in the layout, they are not displayed, and the default error styling is not applied.
The showError trigger enables you to catch and report a server-side error in the browser, even if the field in error is not in the current view. For example, you could:
- Disable the default error styling and apply custom styling for bound errors
- Display an error for a field that is present in the data layer but not in the current view.
- Display a list of errors.
When DSP data is submitted from the browser, the data is validated on the server to prevent incorrect data from being stored in the database.
By default, if an error is found, the error is reported back to the browser and default error reporting is applied—error class
-ufld-highlight-error- is applied to the field in error, and if a bound error element is present in the layout, it is displayed. The trigger gets fired even if the field is not present in the layout.
You can use the showError web trigger to disable the default error styling and apply custom styling when a server validation error occurs. In cases where the field in error is not visible in the layout, you could report the error in another way, such as an alert box.
You can use the clearError trigger to reverse the effects defined in the showError trigger. For more information, see webtrigger clearError.
Note: The showError and clearError triggers cannot be used to activate operations on the server. This will result in a uniface.UnifaceError exception. If your own code does not catch this exception, Uniface displays the resulting uniface.UserFunctionError in a message window.
this keyword refers to the uniface.FieldErrorContext object rather than the uniface.Field object. This object provides a number of functions for accessing the field that was in error, the DOM node the represents the field in the layout, and the validation error itself.
This ensures that even if the field was removed during the update, it is still possible to clear the error that it caused.
The following trigger styles the field in error.