How to figure out if a related foundset was in find

Questions, tips and tricks and techniques for scripting in Servoy

How to figure out if a related foundset was in find

Postby patrick » Fri Sep 16, 2011 3:15 pm

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
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

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

Postby rgansevles » Mon Sep 19, 2011 8:50 am

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
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

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

Postby patrick » Mon Sep 19, 2011 9:10 am

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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

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

Postby rgansevles » Wed Sep 21, 2011 11:06 am

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
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

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

Postby lwjwillemsen » Wed Sep 21, 2011 12:32 pm

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,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 680
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

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

Postby martinh » Wed Sep 21, 2011 2:13 pm

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.
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium


Return to Methods

Who is online

Users browsing this forum: No registered users and 8 guests

cron