How to control warning in Servoy 6

Questions and answers regarding the use of eclipse environment as seen in Servoy Developer

How to control warning in Servoy 6

Postby Marco R. » Mon Oct 10, 2011 1:12 pm

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
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How to control warning in Servoy 6

Postby ROCLASI » Mon Oct 10, 2011 1:23 pm

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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: How to control warning in Servoy 6

Postby Joas » Mon Oct 10, 2011 1:57 pm

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.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: How to control warning in Servoy 6

Postby Marco R. » Mon Oct 10, 2011 2:29 pm

Ok!

Thank you all for your answers.
It will be usefull.
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How to control warning in Servoy 6

Postby Marco R. » Tue Oct 11, 2011 2:48 pm

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
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How to control warning in Servoy 6

Postby jcompagner » Tue Oct 11, 2011 6:00 pm

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}}>
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How to control warning in Servoy 6

Postby Marco R. » Wed Oct 12, 2011 10:04 am

Thanks Johan!

I'll use it for any future necessity!
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How to control warning in Servoy 6

Postby Marco R. » Wed Oct 12, 2011 1:07 pm

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
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How to control warning in Servoy 6

Postby jcompagner » Wed Oct 12, 2011 3:01 pm

no you dont miss anything thats currently a bug in 6.0.1 (the removal of the { } )
Is already fixed for 6.0.2
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How to control warning in Servoy 6

Postby Marco R. » Wed Oct 12, 2011 3:33 pm

Ok thanks, I'll wait for it!
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm


Return to Eclipse Environment

Who is online

Users browsing this forum: No registered users and 2 guests

cron