controller vs databaseManager FoundSet ?

How do you get a FoundSet in Servoy 6 ?

This works ( count = 9 ), but is deprecated:

var fs = controller.duplicateFoundSet();
var count = databaseManager.getFoundSetCount(fs);

and this fails ( count = 0 ):

var ds = controller.getDataSource();
var serverName = databaseManager.getDataSourceServerName(ds);
var tableName = databaseManager.getDataSourceTableName(ds);
var fs = databaseManager.getFoundSet(serverName,tableName);
var count = databaseManager.getFoundSetCount(fs);

greg

Hi Greg,

gdurniak:
and this fails ( count = 0 ):

var ds = controller.getDataSource();
var serverName = databaseManager.getDataSourceServerName(ds);
var tableName = databaseManager.getDataSourceTableName(ds);
var fs = databaseManager.getFoundSet(serverName,tableName);
var count = databaseManager.getFoundSetCount(fs);

databaseManager.getFoundSet() function always returns an empty foundset. You need to first load some records in there using the loadRecords() function.

Hope this helps.

I thought a FoundSet was just a list of Primary Key values

what then does fs = databaseManager.getFoundSet(serverName,tableName) actually do ?

and if I’m looking at a found set of 9 records in a form list, what is the easiest way to “grab” this FoundSet ?

greg

gdurniak:
if I’m looking at a found set of 9 records in a form list, what is the easiest way to “grab” this FoundSet ?

“foundset” is all you need for code on the form. Code from another location:

var fs = forms["formName"].foundset
application.output(fs.getSize()) // = 9

Hi Greg,

A foundset is an object that is linked to a table (and therefor a server connection as well). It may or may not hold any PK’s (and fetched/changed data) from that table.
Using the databaseManager.getFoundSet() gives you just that. An empty foundset. In fact it’s also a non-linked (as in separate) foundset.
Being a separate foundset it means it won’t have the same 9 records that your form has.

But to be able to give you a better answer to your question let me ask you what you want/need to do exactly?

Thanks. That does answer my question.

I was just trying to update a deprecated statement, and got sidetracked playing with databaseManager

so:
var fs = controller.duplicateFoundSet(); becomes
var fs = foundset.duplicateFoundSet();

Another question: I can see why “foundset” is shown under each Form, but why not in Database Manager ?

and if Servoy’s “controller” and “foundset” objects are similar, why are “controller” and “foundset” represented differently in the Solution Explorer ?

since I don’t use Servoy everyday, I find it hard to find things …

greg

PS
and why not more meaningful names, perhaps databaseManager.getNewFoundSet(serverName,tableName) ?

this was also helpful http://www.servoymagazine.com/home/2011 … taset.html

controller and foundset are completely different things…

controller is a ui thing, controlling the forms ui stuff (like selecting an index, requesting focus and that stuff)
also a controller has the showFoundset() method so that it can show a foundset in the ui.
yes it has methods that are passed through to the foundset
The foundset object is the object that holds the data/records from the table.

But why are you trying to duplicate foundsets? What are you doing with the duplicates?

because in the first post you do:

var fs = controller.duplicateFoundSet();
var count = databaseManager.getFoundSetCount(fs);

why is that?
why not

var count = databaseManager.getFoundSetCount(foundset);

I am looping thru the current found set, to copy certain records to the duplicate found set

taken from a method I found on the Servoy Forum

greg

PS
If the Solution Explorer shows find() and search() for Controller, why not for Foundset ?

gdurniak:
If the Solution Explorer shows find() and search() for Controller, why not for Foundset ?

what are you talking about? JSFoundset object has both of them, and they are shown just fine the the Solution Exporer.

It’s not that anything is missing, It just seems “Foundset” itself is so commonly used, it could be it’s own section in the Solution Explorer

so that I could “move code”, and ger Foundet.find() in one shot

( but this would just repeat everything in JSFoundset, so is not practical )

just a comment, not a problem :-)

greg