onLoad fires multiple times

Env :
Servoy Developer
Version R2 2.2.5-build 337
Java version 1.5.0_07-b03 (Windows XP)

This is what “ServoyDevUserGuide-2.2.3.pdf” says about ‘onLoad’:

The method that is triggered when a form is loaded from the
repository the FIRST TIME; used to alter elements, set globals,
hide toolbars, etc; onShow method can also be assigned.
NOTE: onShow should be used to access current foundset
dataproviders; onLoad cannot be used because the foundset data
is not loaded until after the form is loaded.

So, from that description…

if Form_A is loaded (and the user navigates some records etc) and then he swaps to another form, Form_B, (the user does some work)…then swaps back to Form_A. At this point, ‘onLoad’ should not be fired, correct ?

If so, why do we OCCASIONALLY see the method ‘onLoad’ fired again ?

‘onLoad’ is the ONLY form event on this form which we have configured to anything but DEFAULT.

mtia
julian

Servoy can keep forms in memory (a stack). Lets say 30.
So at one point form 1 can drop out of that stack when you load form 31.
When you access your first form again it has to load it. Hence the onLoad event gets fired.

Hi Robert :)

So, you’re telling me that you know the implementation of the form caching within Servoy. That’s good information to have :)

But, that doesn’t explain why the doc states what it does.
The doc is very clear in what it states.
Perhaps the doc should say what you’ve just explained ?

I wonder why they would use a java.util.Stack of size 30 for the Form instance management ? I wonder…

Oh…and if Forms did "drop off’…then it’s more likely to be q Queue instead of a Stack…I think !

Any ideas ??

J

Hi Julian,

No I don’t know the exact implementation of this cache function. But I’ve been told by people of Servoy that it keeps a stack of the most used/requested forms in memory. So eventually a lesser used form will drop out of this cache and when you request it again it will have to be loaded up again, thus firing the onLoad event.
I believe the amount of forms is memory related, not a hard form count.

Thanks for your help Robert :)

Uh oh… do I understand correctly that it is not possible to rely upon onLoad to only execute once per session?

Jim

I guess you can assume that. But let the people of Servoy confirm this.

By the way, if you want to be sure that a method is only called once I suggest you place it in Solution Settings under ‘On Open method’.
Or set a global variable that a method is already called…etc.

Hope this helps.

Thank you, Robert! Yes, very helpful.

May I suggest (Marc Norman) that the fact that OnLoad may be triggered multiple times is made clear in the documentation?

Jim