Page 1 of 1

How to control warning in Servoy 6

PostPosted: Mon Oct 10, 2011 1:12 pm
by Marco R.
Hi all,

I've this kind of code:

Code: Select all
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

Re: How to control warning in Servoy 6

PostPosted: Mon Oct 10, 2011 1:23 pm
by ROCLASI
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.

Re: How to control warning in Servoy 6

PostPosted: Mon Oct 10, 2011 1:57 pm
by Joas
Marco R. wrote: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:
Code: Select all
/** @type {JSFoundset<db:/my_repository/my_table>} */
var _myFoundset = databaseManager.getFoundSet("my_repository","my_table");
_myFoundset.my_field = "hello"

Then the warnings will disappear.

Re: How to control warning in Servoy 6

PostPosted: Mon Oct 10, 2011 2:29 pm
by Marco R.
Ok!

Thank you all for your answers.
It will be usefull.

Re: How to control warning in Servoy 6

PostPosted: Tue Oct 11, 2011 2:48 pm
by Marco R.
Ok, one last thing:

I've a MEDIA variable called "root".

At the startup a global fuction will instantiate "root" as Object()
Code: Select all
globals.root = new Object()


I use it as an Object array by:
Code: Select all
globals.root[_myCurrCollection] = new Object()



and fill its variables:
Code: Select all
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:
Code: Select all
/** @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

Re: How to control warning in Servoy 6

PostPosted: Tue Oct 11, 2011 6:00 pm
by jcompagner
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}}>

Re: How to control warning in Servoy 6

PostPosted: Wed Oct 12, 2011 10:04 am
by Marco R.
Thanks Johan!

I'll use it for any future necessity!

Re: How to control warning in Servoy 6

PostPosted: Wed Oct 12, 2011 1:07 pm
by Marco R.
I've tried to follow what you have suggested and I've put for example:

As global:
Code: Select all
/** @type {Object<{{MyName:String}}>}*/
var root = new Object()


but when I save the changes it becames:

Code: Select all
/** @type {Object< MyName:String  >} */

with warning "Unknow type MyName."

Into the wiki I've found:
Code: Select all
{ {name:String, age:Number}}


so I've tried to put
Code: Select all
/** @type {{MyName:String}}  */


but after saving I obtain
Code: Select all
/** @type {MyName:String} */

with warning "Unknow type MyName".

Am I missing to do something?

Thanks

Re: How to control warning in Servoy 6

PostPosted: Wed Oct 12, 2011 3:01 pm
by jcompagner
no you dont miss anything thats currently a bug in 6.0.1 (the removal of the { } )
Is already fixed for 6.0.2

Re: How to control warning in Servoy 6

PostPosted: Wed Oct 12, 2011 3:33 pm
by Marco R.
Ok thanks, I'll wait for it!