controller.DuplicateFoundSet problem

Hello,

I have the following problem:

There are two forms, based on the same table sharing the same found set (one record view, one table view). In table view there are some globals with search functionality attached (filters). The user can choose a value from the global, a search is triggered and the results are shown.

In order to prevent empty found sets, I make a duplicateFoundSet before the search and load that if nothing is found. If that happens, the FoundSet before the search is correctly loaded in table view, but the form view is empty (no records).

I think the two forms should have the same found set after restoring the original found set, shouldn’t they?

Thanks
Patrick

you have to set both forms to use that foundset!
So only setting one form back doesn’t bring back the other.

I am not sure I understood this right? What do you mean by

set both forms to use that foundset

?

As long as I understood the concept of forms, all forms based on one table share the same foundset as long as you don’t check “use different found set” in one of them…

OR if you set it yourself
Like related foundsets or copied foundset.
Then ofcourse the foundset isn’t shared anymore.

so if you set a related or duplicated foundset in one form then that form is the only one using that foundset. So if you want other forms also to use that fs then you have to set them.

hmm. That means everytime I have a controller.loadrecords and I want all forms to use that, I have to manually do that?

I came across this using a table view and a record view form (the typical list/single view). In table view I have features for searching etc. that might lead to a controller.loadrecords. So in that case I have to set my record view the same?

This does obviously not occur if Servoy loads records, e.g. when searching, right?

Thanks.

if you start changing the foundset’s youreself. then you have to maintain them yourself. That is just the way it works.

We currently just don’ have a way to push a copied foundset as the shared foundset so that then suddenly all the forms have this foundset.

but now i am thinking a bit more about this you could do i think this:

var currentFoundset e = foundset;
var dupped = controller.duplicateFounset();
controller.loadRecords(dupped);
controller.find();
xxx = yyy;
controller.seach();

if results are not satisfactory then set the previous current foundset back

controller.loadRecords(currentFoundset)

that currentFoundset will be the sharedFoundset.

IF the results are OK and you also want these records to see in another form then you have to set this foundset in the form also ofcourse!!
[/code]

Thanks for the help! Your code does work.

The only thing: I don’t really understand why it has to be that way. Could you explain a little, why you do the things you do?

Thanks.

hmm. And I still have one problem with this…

This doesn’t work:

var currentFoundset e = foundset;
var dupped = forms[a_form].controller.duplicateFounset();
forms[a_form].controller.loadRecords(dupped);
forms[a_form].controller.find();
xxx = yyy;
forms[a_form].controller.seach();

My custom controller is used on two forms (table and record view). This method needs to be run from there, so I used abstract notation form the form used…

The method does work, but the forms are out of synch after restoring the original found set…

I am still struggling with this problem. It looks like the behaviour has changed again in 2.1rc1. When using this code

var currentFoundset = foundset;
var dupped = controller.duplicateFoundSet();
controller.loadRecords(dupped);
controller.find();
a_field = '%text%';
if(!controller.search())
{
	controller.loadRecords(currentFoundset);
}

I get the following results:

  1. when no records are found, everything is fine
  2. when records are found, getMaxRecordIndex tells you the right number of records but you don’t see them. When switching from a table view to record view and back, you see the foundset in table view. Going back to record view, you see all records (forms are “out of synch”).

Any ideas?

A similar problem occurs when I try to do this:

globals.filter = '%' + globals.filter + '%';
controller.loadRecords(filter_LIKE_to_data);

The relation filter_LIKE_to_data looks like this “globals.filter-LIKE-data.field”.

What happens here is just like what I describe above under 2).

I thought this would be a nice way to achieve “home scripted” quick searches… Is this supposed to work at all?

  1. when records are found, getMaxRecordIndex tells you the right number of records but you don’t see them. When switching from a table view to record view and back, you see the foundset in table view. Going back to record view, you see all records (forms are “out of synch”).

That first thing, not seeing the foundset in the tableview right away is a problem in 2.1rc1. We will bring out rc2 very soon, because this is pretty serious bug that got introduced with the many performance enhancements.

second thing, that the foundset are out of sync is logical. Because if you find something then you keep the dupped foundset, And that dupped foundset is not a global foundset, So if you also want to see the results in the recordview you have to set it in the record view:

var currentFoundset = foundset; 
var dupped = controller.duplicateFoundSet(); 
controller.loadRecords(dupped); 
controller.find(); 
company_name = '%' + globals.searchField+  '%'; 
if(!controller.search()) 
{ 
   controller.loadRecords(currentFoundset); 
} 
else
{
	forms.companiesRecordView.controller.loadRecords(dupped);
}

But then you have a problem that you never get the shared foundset again in those 2 form so you have to sync them always by hand (if you do for example CTRL-J on one of them)

The problem is that we don’t currently have a call where you can set the global shared/table foundset youreself.

I don’t know much about Servoy “behind the scenes”, but what I would expect Servoy to do is this:

As longs as I don’t check “Use seperate found set” all forms based on one table should always share the foundset whatever way they were created without me doing something.

The interface where you have a table and a record view is the most common thing. Once you search around in table view, restoring found sets or loading something “manually”, you are broken in a way, that the user cannot go to record view with expected results. If that is the case, controller.loadRecords is rather dangerous to use…

just to explain once more
If you use loadRecords then that foundset will not be the shared foundset. Because most of the time you are setting a related foundset this way.

Because you now can duplicated normal (shared) foundsets. Then you suddenly have 2 foundsets. And if you use that one in loadRecords then yes this will NOT be shared. Just like a related foundset will NOT be shared when you use loadRecords.

What you want is that you can set somehow that the foundset you set now (if non related) must be from now on the shared foundset.

I don’t think we can just say, if you set a non related foundset in the loadRecords then it will be shared. Because then suddenly you can’t use the dubbed foundset the way others use it (to really get a clone and only use that one) But i don’t know how people look at this exactly.

OK, thanks for the explanation. I think this has to be discussed a little further… :wink:

I use this setup up of table/record view really often, so this is an important issue. As far as I see now, I don’t have this problem in portals, where I have the same setup of table/record view, but related. I will do some further testing, but what works fine for me.

As far as I understood the discussion now, I keep my hands off loading records in my main tables. Because once that happens, the user has to re-login in order to make it work again, if I see that right.

We changed it so in 2.1RC3 loadAllRecords will revert back to the shared foundset.

so if you if you do a controller.loadAllRecords in RC3 and the form doesn’t have the useSeperate property set, it will revert back to the shared one.