Marco_R
October 10, 2011, 11:12am
1
Hi all,
I’ve this kind of code:
var _myFoundset = databaseManager.getFoundSet("my_repository","my_table");
_myFoundset.my_field = "hello"
and I obtain a warning like “the property ‘my_field’ is undefined for the type JSFoundset”.
I wouldn’t this kind of warning: the only way is to disable it from the preference?
or does exist a way to write it to avoid this warning? (I wantn’t use a design form foundset)
Thanks for the help
Marco
ROCLASI
October 10, 2011, 11:23am
2
Hi Marco,
When you use the databaseManager.getFoundSet() function you get an empty foundset so you first need to load any record(s) or create them in this foundset.
Hope this helps.
Joas
October 10, 2011, 11:57am
3
Marco R.:
or does exist a way to write it to avoid this warning?
You can use jsdoc to let Servoy know what kind of foundset is in the variable:
/** @type {JSFoundset<db:/my_repository/my_table>} */
var _myFoundset = databaseManager.getFoundSet("my_repository","my_table");
_myFoundset.my_field = "hello"
Then the warnings will disappear.
Marco_R
October 10, 2011, 12:29pm
4
Ok!
Thank you all for your answers.
It will be usefull.
Marco_R
October 11, 2011, 12:48pm
5
Ok, one last thing:
I’ve a MEDIA variable called “root”.
At the startup a global fuction will instantiate “root” as Object()
globals.root = new Object()
I use it as an Object array by:
globals.root[_myCurrCollection] = new Object()
and fill its variables:
globals.root[_myCurrCollection].myLength = 0;
globals.root[_myCurrCollection].myWidth = 100;
globals.root[_myCurrCollection].myCandies = 200;
globals.root[_myCurrCollection].myList = new Array()
etc..
At now it’s all ok but when I point to “globals.root[_myCurrCollection].myLength” by a form-function, I obtain a warning as “undefined in javascript”.
I’ve tried to use:
/** @type {Number} */
over the variable initialization but I suppose that it works just into the instance case.
What is the right way to solve this?
Thanks in advance.
Marco
look here:
http://wiki.servoy.com/display/public/D … sing+JSDoc
under the section Object Type and so on
in your example globals.root looks a lot like:
Object<{{myLength :Number, myWidth :Number,myCandies :Number, myList :Array}}>
Thanks Johan!
I’ll use it for any future necessity!
Marco_R
October 12, 2011, 11:07am
8
I’ve tried to follow what you have suggested and I’ve put for example:
As global:
/** @type {Object<{{MyName:String}}>}*/
var root = new Object()
but when I save the changes it becames:
/** @type {Object< MyName:String >} */
with warning “Unknow type MyName.”
Into the wiki I’ve found:
{ {name:String, age:Number}}
so I’ve tried to put
/** @type {{MyName:String}} */
but after saving I obtain
/** @type {MyName:String} */
with warning “Unknow type MyName”.
Am I missing to do something?
Thanks
no you dont miss anything thats currently a bug in 6.0.1 (the removal of the { } )
Is already fixed for 6.0.2
Marco_R
October 12, 2011, 1:33pm
10
Ok thanks, I’ll wait for it!