Page 1 of 1

How to figure out if a related foundset was in find

PostPosted: Fri Sep 16, 2011 3:15 pm
by patrick
Hello,

I have a related foundset and maybe perform a find() in it. Is there a way to figure out if that foundset is just plain related or further filtered?

Currently I see no way...

Thanks
Patrick

Re: How to figure out if a related foundset was in find

PostPosted: Mon Sep 19, 2011 8:50 am
by rgansevles
Patrick,

There is a method on foundset: isInFind().
Btw, when a foundset is in find mode, calling find() on it will do nothing and return true.

Rob

Re: How to figure out if a related foundset was in find

PostPosted: Mon Sep 19, 2011 9:10 am
by patrick
Rob,

I was aware of that, but I don't think it does what I need.

I have a relation e.g. customer_to_orders. I allow the user to perform a find in that (e.g. filter by product). In my UI I remember what was filtered for what customer ID using form variables.

Now I think that Servoy "caches" these foundsets. So if the user selects customer A, filters the relation, goes to customer B and back to customer A, the relation for customer A will still be filtered. But: at some point in time I guess, these foundsets are no longer cached but reloaded. Then my filter is gone, but my UI still thinks it's filtered.

So my question is: can I find out not if a foundset IS in find, but has been filtered or not. I want to know if the related foundset is the "original" related foundset or further filtered by a find()/search().

You understand what I mean?

Something like: foundset.isFiltered(). This could also be useful for a non-related foundset. A way to find out if a find() has been performed or not.

Re: How to figure out if a related foundset was in find

PostPosted: Wed Sep 21, 2011 11:06 am
by rgansevles
Patrick,

You are right, Servoy keeps a soft cache of related foundset that are reused every time you request a related foundset for the same base record.
If you do a find/search on a related foundset it will change the state of that foundset and anywhere else you show/request that foundset later you may get the filtered one or a fresh one depending on whether the foundset was garbage collected.

To prevent this scenario, do not search in related foundsets, only on copies (customer_to_orders.duplicateFoundSet())

Rob

Re: How to figure out if a related foundset was in find

PostPosted: Wed Sep 21, 2011 12:32 pm
by lwjwillemsen
Hi, we are so unhappy with this default servoy behaviour...
It leads to very hard to find bugs...

How can we get all developers in our team to never use find/search in related foundsets or to always use foundset.loadAllRecords() when using a related foundset :cry:

Regards,

Re: How to figure out if a related foundset was in find

PostPosted: Wed Sep 21, 2011 2:13 pm
by martinh
patrick wrote:
Something like: foundset.isFiltered(). This could also be useful for a non-related foundset. A way to find out if a find() has been performed or not.


How about using databaseManager.getSQLParameters(foundset, boolean includeFilters) ?

If you get parameters in return, then it is a related foundset.
Otherwise it isn't.

This will not help you in all cases, but perhaps in some of them it will.