Omnis Technical Note TNJS0008Dec 2016

Error Handling in Remote Forms & Inheritance

for Omnis Studio 8.0 or above
By Andreas Pfeiffer, Omnis Germany

This tech note demonstrates how error handling in remote forms can be implemented, and how you can use inheritance in tables and JavaScript remote form classes to optimize your Omnis libraries.

There is a library to accompany this tech note which you can download from GitHub: https://github.com/OmnisStudio/Omnis-JSErrorHandling (requires Studio 8.1.2 or above)
(or download an archive: errorhandling.zip requires Studio 8.1.2 or above)

Download the library, open it in Omnis Studio, right-click on the jsCustomerEdit remote form and select Test Form, or open it in design mode and press Ctrl/Cmnd-T: the form should open in your default web browser. Enter some data, but leave the 'name' or 'city' field blank, and then press Save: these are required fields, but if they are left blank an error is written back to the form and displayed in red text next to the field.

Error handling

The library uses a super table class called "tbSuper" that contains the $save code that is used in the form. The "tbCustomers" table class inherits the methods, and the $checkData method is overridden in the table class tbCustomer: each individual table class can have its own business rules, but generic or standard methods can be stored in the superclass.

Regarding the remote forms, the "jsEditSuper" remote form is used in this example as a super remote form class to edit the data. It has an example "Save" button that uses the $save method of the row that is defined from the inherited table class tbCustomer.

When you test the remote form in the browser and press the Save button, the $save merthod of the super table class will call the internal $checkData method, and the internal iErrorList may be filled if the individual business rules fail the error check (in this case the name or city fields are empty). In this case, the $save method will return kFalse. This is then used to call the class method "setFieldErrors" in the jsEditSuper remote form. This method then gets the error list from the datarow and sets the individual error text messages for each field. Finally it sets the cursor into the first field ready to enter some data.

 

Search Omnis Developer Resources

 

Hit enter to search

X