onNextRecordCmd not triggered

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)

onPrev and onNext commands wheren’t implemented yet :(

They are in 2.2RC5!! :)

And will they also respond to something like

setSelectedIndex(getSelectedIndex() + 1)

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…

No they will not, a command is issued by the end-user never by a script

Thanks Johan,

I’ve installed rc5 and they seem to be working very well! :)

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?

Thanks
Patrick

patrick:
…that we could use…

when you whould call your suggested “controller.nextRecord()” you also could call the method which is attached to the nextRecord method

so next could also do:

controller.setSelectedIndex(controller.getSelectedIndex() + 1)
methodWhichIsAttachedToNextRecordCMD()

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.

If you call the “data checker” method validateData() on all forms, you can call that method as:
forms[currentcontroller.getName()].validateData()

But I don’t have a “data checker” on all forms… :) But I see you don’t like my idea… I guess we can manage some other way.

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. :lol:

What do you mean with:

" I could use a controller.nextRecord() that does nothing but the new Record"

so controller.nextRecord() == controller.setSelectedIndex(controller.getSelectedIndex()+1);

and that must call newRecord??

Sorry, typo error: “that does nothing else but the next record command”

but that is just:

form.myNextRecord();

call youreself.

Yes sure, but then I do that on 500 forms myself. This whole thread is about saving my time :lol:

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.

My setup is this:

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. :lol:

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

patrick:
I hope this makes my little problem understandable.

Well not really…
suggestion to get same behavior in a global method as we think you are asking.

currentcontroller.setSelectedIndex(currentcontroller.getSelectedIndex() + 1) 
forms[currentcontroller.getName()].validateData()

so if you name the method attached to onNextRecordCmd everywhere validateData() you are done

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

currentcontroller.setSelectedIndex(currentcontroller.getSelectedIndex() + 1)
forms[currentcontroller.getName()].validateData()

would have to be

forms[formShowingTab].controller.setSelectedIndex(currentcontroller.getSelectedIndex() + 1)
forms[formInTab].validateData()

and how do I know in a global method what form that is?