Websydian v6.1 online documentationOnline documentation - WebsydianExpress v3.0

Reload Page With Errors

Overview

This functionality gives you the option to show a list of errors generated by an event on the page containing the event.

A typical example is in a situation, where you wish to create a record. The creation of the record will almost always be preceded by a validation, which can result in a number of errors.

Instead of showing the errors on a specific error page, it will be beneficial to show the errors on the page, where the information leading to the failed validation was entered.

This section shows how to implement such a functionality.

Inheritance

Specify the following triples for the page the list is to be shown on:

Source Object Verb Target Object
MyPageWithErrorList is a FNC WSYAPI/Abstract.PageGeneratorErrorListForProcess

One of the effects of this is that an input parameter "ErrorMode" is added to the interface of MyPageWithErrorList. If this parameter is set to "*Yes", the error list will be shown.

If MyPageWithErrorList is an existing function, you will have to go through all existing calls to the function and map with "*No". You will also have to regenerate and build all calling functions.

Replace error page for EventHandlers

For each EventHandler, you wish to use the error list for, you must replace the error page with the following triple:

Source Object Verb Target Object
MyEventHandler replaces FNC

...by

WSYAPI/ErrorPageForProcess
MyPageWithErrorList

Please note that if MyEventHandler also inherit from a standard Websydian pattern function, it might also be necessary to replace the WSYBASE/ErrorPage function with MyPageWithErrorList

The function SystemAPI.HtmlChildErrorPageForProcess is a child page, which contains the error list. The function and its template (WSCHERR) are part of the provided runtime.

You can of course define your own error list child page - just let it inherit from SystemAPI.HtmlChildErrorPageForProcess and replace with this function instead.

The EventHandlerForProcess is already an EventHandlerWithValidation so if you just wish to use the standard validation you do not need to do anything else.

Perform custom validation

In some situations you will wish to write the validation functionality yourself.

In this case you must do the following to get a message in the list.

When you have encountered an error ensure that it is registered that the instance is not valid by inserting this code

 

Set WsyBase<InstanceValid> = <InstanceValid.*No>

Create the text to show - and cast this text to Environment<*Message text>.

Write the message to the error list:

 

Go Sub Send message

This writes the message text to the storage, which will be used when showing the error list.

Map ErrorMode parameter

The EventHandlerWithValidation pattern executes the subroutine "error handler" when the InstanceValid field is set to no.

You should check whether the replacement has been successful and the PageGenerator is called. You will have to map the input parameter "ErrorMode" to *Yes.