I want to prevent users from changing records whilst in the middle of editing one, but have run into a problem. The onNextRecordCmd method is not being triggered when I go to a new record, either using the menu or alt + down arrow. Same problem with onPreviousRecordCmd. Is this a bug?
Version R2 2.2rc4-build 322
Java version 1.4.2_06-b03 (Windows XP)
Mostly we don’t show the default controller. We use global methods attached to buttons to move through records, it’d be cool if that sort of thing would also be caught…
Jan Blok:
No they will not, a command is issued by the end-user never by a script
I see. And could you think of something like controller.nextRecord() and controller.previousRecord() that we could use and that would then be caught by the event?
We need to do some checking on field contents in every record. I have a global method for browsing through records. The data checking method is somewhat context specific, so I need to do this locally in a form. Now it’d be cool if I could catch the event when the user browses through records. But the only way he does that is through my global method. My idea was to change the global method to something like controller.nextRecord() and then attach the form-specific “data checker” to those two events.
So the problem is, that I can’t put this
methodWhichIsAttachedToNextRecordCMD()
into my global browse method because “data checker” is different on every form.
hmm. Just tried to solve my “data checker” problem some other way and got in trouble! My data checking has to be done in a form that is shown through a tab panel, but the browse buttons sit in the form of the tab panel itself. So it was very handy if I could use a controller.nextRecord() that does nothing but the new Record command and is caught by the event.
we will not make it sow that form command methods (like onNextRecord/OnXXX) will be called by javascript nextRecord or XXX.
Those onXXX methods are purely for overriding UserInterface behaviour.
Wnhy do you need to do this on 500 forms?? What do you need to control nextRecord for all those forms???
But i don’t get it.
You are willing to program:
controller.nextRecord() but not call youre own nextRecord() method?
If you just want to call controller.nextRecord() or if the method was there nextRecords() on the form yourself.. Then use a global method for this where you test if there is a nextRecord and call then one or set the selectedIndex youreself.
I have a global method that walks through records of any form. It does neat little stuff like showing an inactive back button if you are on the first record and so on. Then I have a global logic for determining and visually marking mandatory fields based on a given form. I also have a global method that checks if any of those mandatory fields are emtpy. I use that onHide of forms and on the form specific save methods.
What I would like to do now is to enhance the method that walks through records to check those mandatory fields. Unfortunately, the mandatory field logic is based on forms. Most of my forms have tab panels that show the actual data. The browse buttons sit on the main form. From the main form I cannot check those mandatory fields.
What would be neat is to attach the global method for checking mandatory fields to the onNextRecordCmd event of the forms shown in the tab panels. But since I globally walk through records using selectedIndex, this event is not caught. So the idea was to change my global browse method to use controller.nextRecord() instead of setting an index. If that could be caught by the event, all I’d have to do is to attach one global method to the forms where I want that method to be fired.
I hope this makes my little problem understandable.
In general I am not to fond of those menu commands. Some of those are extremely dangerous (“Delete all records”) and I think it is dangerous that the default setting activates those. Since we can script all those commands ourselves, it’d be better to not have them at all. In FM I always disabled the menu bar commands and made my own logic. I know I can disable them, but I still think they shouldn’t even exist. I’d rather have a Servoy menu editor that allows me to configure the menu bar as I like.
But since everybody needs to walk through records all over the place, I think an onNextRecord() is a useful event especially for data validation. If you do validation in a method in every form where you need it, you can use the current functionality. If you do that globally like I do, that doesn’t work. That’s all.
patrick:
Unfortunately, the mandatory field logic is based on forms. Most of my forms have tab panels that show the actual data. The browse buttons sit on the main form. From the main form I cannot check those mandatory fields.
We shouldn’t wast too much time on this, but your suggestion doesn’t work because the validation has to be done in a form shown in a tab panel while the navigation is on the main form showing the tab. So this