Why is application.getMethodTriggerFormName() now depricated? (in servoy5)
I understand that you now have a JSEvent, but the problem is that I have lot of methods, that call other methods and only in the third method I need the triggered form.
Do I have to give the form now as an argument from the first method till the last method?? because only the first method will receive the JSObject right?
This is very MUCH work…
(I know application.getMethodTriggerFormName() still works, but depricated means, gone in Servoy 5.5/6? )
I agree harjo, in my oppinion this and application.getMethodTriggerElementName() shouldnt be depricated.
As you say i know we now have the JSEvent but i still find theese quite useful.
We have had cases in the past where it was not safe to call getMethodTriggerFormName() in the xth nested method. To avoid problems, we already pass the result along when we call the next method. So I think what you were (probably successfully) doing in the past was not 100% reliable anyway…
I’ve started pushing the event from method to method and even attaching it to forms as an object for later retrieval, and this has worked very well for us.
Also the event.data is very powerful for storing additional information and pushing it to other methods.
bobbydtma:
I’ve started pushing the event from method to method and even attaching it to forms as an object for later retrieval, and this has worked very well for us.
Also the event.data is very powerful for storing additional information and pushing it to other methods.
That sounds really interesting Bobby - could you elaborate on what you are doing and how that works?
For example, we have an event method that gathers multi-selected records from a table view after the user drags the records to another form.
In the first method we do:
function firstEventMethod(event) {
//Create a new object
event.data.records = new Object();
//Attach the selected records to the new object
event.data.records = foundset.getSelectedRecords()
//We can then push that event to the next method for processing the records.
nextMethod(event);
}
function nextMethod(event) {
//retrieve records
event.data.records
//You can also retrieve the form and element that triggered the original event.
var form = event.getFormName();
}
Technically, you could pass the event and record objects separately and achieve the same results, but I like having the ability to keep all the information together in one neat “package.” And, if we want to attach additional information to the event.data we can easily do that and still only pass the single event to other methods.
//Create a new object
event.data.records = new Object();
//Attach the selected records to the new object
event.data.records = foundset.getSelectedRecords()
i guess you mean:
//Create a new object
event.data = new Object();
//Attach the selected records to the new object
event.data.records = foundset.getSelectedRecords()
What about calculations?? Im using application.getMethodTriggerFormName() in a calc to control it, cause i need the calc to operate differently, or not operate at all depending on the form that made it run. Do calcs recieve events as well?
nromeou:
What about calculations?? Im using application.getMethodTriggerFormName() in a calc to control it, cause i need the calc to operate differently, or not operate at all depending on the form that made it run. Do calcs recieve events as well?
no calculations are executed in the data layer shouldnt touch form/ui stuff.
Calcs cant be executed from all kinds of events, forms dont have to be the trigger at all.