I’ve been noodling field validation for the past day or so, and have come to a few conclusions:
It would be great if we had column level validation
Right now validation is done through methods and the UI
It requires that the interface be locked down completely
(that can be really a lot of work)
So I was thinking about potentially simple enhancements to Servoy that might make this easier. Here is one idea that came to mind… if others have proposed this in the past my humblest apologies.
The real problem as I see it is that the user interface gives the user lots of options to navigate or perform other actions (i.e. new record, change records, etc). All of these other actions are performed through method control.
So I got to thinking… what if we had method statements that gave us the abiliy to:
Prevent all methods from running
Prevent all methods from running except those called by events
Prevent all buttons from working
So… on recordEditStart we disable all methods (perhaps except those called by events). Then on recordSave we turn on all methods again. Or we do the same by disabling all buttons.
What I’m really looking for is a simpler way to lock down the interface, and right now it requires a lot of manual effort.
Hmm, I don’t understand what you think/want I guess but what about controller.readOnly() to set/get the readonly state of all elements on a form instead of setting them on an element level. The same with enable. These two are very effective. On a form and on element level…
I think that I see where Rich is coming from here.
I guess that Rich has been trying to achieve a viable way of controlling the user’s interaction with the solution (something indicated by another of his posts reporting a suspected bug in kiosk mode on Mac) with a limited overhead involved
As soon as you begin to edit a record then, in general, the user can still engage the drop down menu commands and initiate new/delete/sort etc etc record commands unless you can suppress them
So it is not the need to set the readOnly() state of the current record that is needed, it is rather to disable everything else whilst editing is happening and enable them again once complete - like locking the user into a transaction and let them out once data is entered and has met necessary and required validations - but do this through a single function that wraps it all together.
On the other hand, Rich may tell me that I am completely off my head - which he knows full well that I am
Rich, I would be interested to know whether you have looked at and discounted something like Marcel’s own Menubar PlugIn which might assist with this sort of principle ?
If I have validation for multiple fields on a form it seems like the right place to do the validation is onRecordSave. If, however, the user presses a button that navigates to a different form I really have no way of stopping that (that I am aware of anyway). Validation in Servoy really requires that the UI be locked down tight, so that we can keep the user on the correct form and record.
My earlier ideas were approaches that I’ve considered to get this done in the simplest manner. Otherwise I end up having to include code in lots of methods to control when the method can/should run.
If, however, the user presses a button that navigates to a different form I really have no way of stopping that (that I am aware of anyway).
Are you referring to toolbar buttons here? Because when they are your buttons you can do whatever you want right? If not Harry is right. You can use the menubar plugin to take out menu/menu choices…
Validation in Servoy really requires that the UI be locked down tight, so that we can keep the user on the correct form and record.
What do you mean by the ‘Validation in Servoy’ bit? In fact that can be archieved by those controller.readOnly and enabled functions. So I would say, freeze the interface, evaluate and remain on the form or move on…
Why do you want/need to create many methods?
When I misinterpret again I will shut up in this thread otherwise glad to have been of help
It would be great if we had column level validation
You’re absolutely right Rich.
Doing validation in the GUI is a tedious job.
That’s why we think column level validation is something that has to come in.
We haven’t worked out details on implementation yet, but it’s definitely a subject “waiting in line”.
First, thank you for your continued info on this thread. I’m not sure I’ve been as clear as I would like, and actually Harry did a much better job in describing my needs than I did!
I tried to used the controller.readOnly property and that does lock down the form nicely. But it also locks down the fields, preventing the users from entering and editing data.
I would like users to be able to enter and edit data, and have that data validated properly, while preventing the user from invoking any other action (i.e. navigation, new record, delete record, change record) until such time as they have satisfied all data validation requirements.
Does this make sense?
Thanks again,
Rich
P.S. Will you attend ServoyWorld this year? If so it would be my pleasure to by you a beer!
The important stuff first Yes, I am a Gold Sponsor of Servoy World and I also do one of the pre-conference trainings on Javascript. I would love that beer…
What you ask for makes sense and now I understand completely (I hope).
To be honest you are probably not going to like my answer. What you can do is name your buttons and disable them until you want them enabled for whatever reason. You can do so via the element properties.
You will have to disable the menuitems for the tasks you mention via the properties menu of the form.
Now you should be able to do whatever you want via the onDataChange for validation and mayby onFocusLost.
Another route is not to disable anything but add a method to the beginning of every button method doing your evaluation.
In the last case you can also add that method to the form properties for delete etc.
I think you would typically set a global onRecordSelect…
Hope this helps otherwise I’m afraid I run out of ideas.
I have written PostgreSQL triggers (BEFORE UPDATE, INSERT OR DELETE) which throw exceptions under certain circumstances, which are picked up by Servoy and displayed as error messages. In my case, I wanted to lock invoices and prevent them from being modified after a certain flag had been set.
I’m sure you can use the same technique for almost anything. It is not that difficult to do.
However, I’m sure the Servoy team already has something on their todo list which will make all this redudant…
Yes, we are now on the same page. Those were the two options that I thought were available as well.
I chose the path of a consistent naming convention for all elements that should be disabled during data entry/edit. I disable them onRecordEditStart, and only enable them when they pass validation in my onRecordSave event.
By default we will be using MySQL per the customer’s requirements. However it is possible that this system will be installed in multiple locations where the final end user may want us to use their preferred backend database.
Since we cannot be sure what databases may be used, we really need to utiliize a database agnostic approach.
And, yes, I’m interested to see what the Servoy folks can come up with… they really are a clever bunch of people!
Just adding my thoughts to this.
I also needed to something similar to FM validation that certain fields had something in them or the correct values.
I added a ‘checkRequired’ method to the ‘onRecordSave’ property for the form. This catches any change that the user might do that would cause a record save, e.g. form change, record change etc.
My method then checks the ‘required’ fields and calls global methods for each field that loop until the field is filled in correctly, getting the user to fill in the value into a dialog that is then RETURNed to the calling method.
It’s not the most elegant of solutions and it doesn’t keep the user on the form neccesarily, but it works.
If you want some example code, let me know.
Thanks for the info. We looked at several different approaches, and settled on one where we disable most buttons on screen onRecordEditStart. The buttons are only enabled onRecordSave, and only if the user entry passes all validation.
The thing I like about your approach is that with a form-in-dialog we can prevent the user from closing the dialong using a “return false” syntax, so the user cannot leave the form until they pass all your validation rules. We are essentially doing the same thing by keeping the user on the same form and record until they pass validation. The bad news is both methods are less than desirable from a UI perspective.
As my Dad, a former school teacher, used to say “All you can do is the best you can”.
All we can do now is hope that Servoy implement things at the table level at some point in version 3…
Otherwise they could add a ‘validation’ property to form elements that we can add a method to, like onDataChange…