I am upgrading from 6.1.4 to 7.1.0. The first new warning I find says “The property currentcontroller is deprecated.” There is no reference to currentcontroller in the list of deprecated API on the Servy 7.1.x section of the wiki and the section of the Reference Guide that documents currentcontroller doesn’t mention anything about it being deprecated. What code should I be using instead?
Thanks,
Steve in L.A.
Hi Steve,
this certainly IS a surprise…
Just looked into the release notes, but no mentions either!?!
Normally you should be able to hover over any deprecated code holding the alt-key and get the substitute for it.
Unfortunately this has been left behind as well.
Anyway, I think the below code should do the job…
var _jsWindow = application.getActiveWindow();
_jsWindow.controller
Created a case to complete documentation on this: SVY-4474
Thanks Marc. Your code example works perfectly.
Steve in L.A.
why not simply using “controller” ?
Back in the good old days, I could address the controller of whatever was the current form by using currentcontroller. Now that Servoy gives us so much control over specific windows and the ability to pinpoint the current window and thus the “current” form, I understand how it is better to use that specificity to get exactly the form’s controller I want.
I can answer you in two ways…
Version 1:
yep Steve !
Version 2
today.autstandingAnswers.servoy[‘nicePeople’].notEurope.SteveInLA.setFunnyText(‘you are right !’)
Hi all:
In v6.0 I use a form as navigator, the form shows the number of records of the foundset using this code:
databaseManager.getFoundSetCount(forms[currentcontroller.getName()].foundset)
Now, in v7, I replace it with this code (as Marc suggests):
databaseManager.getFoundSetCount(forms[application.getActiveWindow().getName()].foundset)
But I receive an error:
TypeError: Cannot read property "foundset" from undefined
This is because getName() returns null.
I don’t know how to replace currentcontroller in this context, any ideas? Thanks!
I found the solution:
databaseManager.getFoundSetCount(forms[application.getActiveWindow().controller.getName()].foundset)