Forms which use separate foundsets lose their data

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Forms which use separate foundsets lose their data

Postby rossent » Thu Nov 21, 2013 3:55 pm

Hi Servoy,

When a form with property namedFoundSet=DEFAULT is unloaded automatically by Servoy, it keeps its foundset state (loaded records and selected record)
When a form with property namedFoundSet=SEPARATE is unloaded automatically by Servoy, it loses its foundset state.

Is this a bug or the "designed" behavior? If this is the "designed" behavior, what is the reason behind it?

As far as we are concerned, the forms & their associated foundsets should keep their state regardless of the namedFoundSet property when Servoy automatically unloads them. When developers manually unload a form (by using history.removeForm) then the form foundset can be unloaded (if SEPARATE).

If Servoy cannot restore the state of something OR cannot provide the necessary means for the developers to restore that state, it should not unload forms and data! If there is some memory pressure or other condition in such cases - fire an event or throw an exception to notify the code and leave it up to the developers to decide what to do - do not just go behind our back and unload stuff.

With the current behavior we are facing a problem which cannot be resolved. Consider this:

1) the user opens 2 forms on 2 different tabs
2) in Form A (which has namedFoundSet=SEPARATE), the user loads data using a query similar to "load all records with status = Active"; this returns 50 records; the user then changes the status of 2 of those records to Inactive and saves the changes (however all 50 records remain visible in the grid); one of the records with Inactive status is currently selected;
3) the user switches to the other tab and performs some operations which trigger Servoy to unload Form A
4) the user then switches back to the tab with Form A.

Issue: currently, form A will show but it will be empty (no records will be displayed in the grid)

a) If we preserve the foundset query upon form unload and then use it to fetch the data back again on the re-load, only 48 records will be fetched AND there will be no way to "select" the inactive record (since it will not be included in the foundset)
b) if we preserve only the PK of the selected record, when the form is re-loaded we can load that record back, but the user expected 50 and not only 1 record
c) keeping the list of PKs of all loaded records is out of question (imagine if the result from the original query was 50000 and not just 50 records)
d) keep a reference to the whole foundset and then "load it back" in the form upon re-load - would love to do that IF there was some distinction in the form Unload event to let us know if it was triggered by our code (with history.removeForm) or by the Servoy automatic unload mechanism. Without that distinction however, we risk keeping in memory data which is not needed anymore. Unfortunately, the form Unload event does not tell us what invoked it. Now we have to do some nasty work-arounds and wrap the history.removeForm in our own "wrappers" just so we know in the form Unload event if we need to keep the form foundset or not, and if someone forgets to use the wrapper, we end up with a "memory leak".

In short - when the user switched to the second tab, he/she left Form A in one state and expected it to remain in that state, however we cannot restore that state no matter what we try. Using DEFAULT foundsets in our case is out of question because we need to be able to show multiple instances of the same form on multiple tabs.
Rossen Totev
Argos Software
rossent
 
Posts: 288
Joined: Wed Dec 31, 2008 2:03 pm

Re: Forms which use separate foundsets lose their data

Postby jcompagner » Mon Nov 25, 2013 1:07 pm

if you just have such a form that you don't want to be unloaded then register the form to a global variable (can be a object/array having forms)
Then we will not unload it.

We can't restore that state at all, because that would mean that we also have to keep all separate foundsets in memory which is not really possible.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Forms which use separate foundsets lose their data

Postby rossent » Tue Nov 26, 2013 1:24 pm

We do not need to pin the whole form in memory - only its foundset.

As to the different behavior of the forms depending on their namdedFoundSet property (DEFAULT vs SEPARATE) - there must be something somewhere written in bold letters which explicitly states that the when Servoy automatically unloads such forms, all their state AND data will be lost!

I still do not see why this cannot be done by Servoy - after all you are doing this for the DEFAULT foundset! I guess, the foundsets which you are currently "keeping" after form unload are linked to their datasource name and not the names of the form(s) instances which are using those. Can't this be changed? You do not need to keep all foundsets in memory - only the ones which are linked to forms which you unload. It has to be either this, OR you provide us with a notification/distinction in the form onUnload event to let us know that you/Servoy is unloading the form due to memory pressure and it is not our code which is doing the unloading. If you provide at least that, then it will be easier for us to keep references to things which we know will be needed the next time when the form is re-loaded.
Rossen Totev
Argos Software
rossent
 
Posts: 288
Joined: Wed Dec 31, 2008 2:03 pm


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 5 guests