Unload changes the form structure

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

Unload changes the form structure

Postby maria.kyselova » Mon Nov 24, 2014 2:05 am

Hi guys,

This is my first time seeing Unload() event in action and it's doing something not quite expected.
My solution has multiple windows and every window is made of clones of the original window. Literally each form is a solutionModel clone, because I need to show the same window on the screen more than once at any particular time.

The problem appears when I open more than three or four windows and 'pre-load' a couple of them in memory without showing them to the user. Servoy starts its own memory management and unloads some forms, that are not currently on the screen.

Now, when I bring those forms up on the screen, Servoy loads them back, however they have original tab forms links.
I'll explain.
When I clone a window, I also clone all forms on its tabpanels.
After the cloning has finished, I load the forms (just calling forms[formName]) and then remove all original tabs and replace them with the cloned tabs.
So, if I had form 'job' that contained a tabpanel with form 'job_details' (that's stage 1), after cloning (stage 2) it will be 'job_clone' containing 'job_details' and after loading form 'job_clone' (stage 3) it will be 'job_clone' containing 'job_detail_clone'. Tabs are removed with .removeAllTabs() and put back with .addTab(), so it's not solutionModel changes.

Everything is fine till the point when Servoy unloads some forms, like 'job_clone'.
When it brings it back and reloads it, the form is back to stage 2: form 'job_clone' has tab 'job_detail' instead of 'job_detail_clone'. Obviously it ruins a lot of things, as I rely on a particular form being in a particular tab.

I would like to know if that is what is supposed to happen or it's a bug, it doesn't sound right.

Also, I'd like to know how to deal with it. I assume I'll be advised to replace tabs at the cloning stage with solutionModel, but that is how it used to be and we refused that method for a few reasons.

Thanks for your feedback, looking forward to a discussion.
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Unload changes the form structure

Postby mboegem » Mon Nov 24, 2014 2:16 pm

maria.kyselova wrote:I would like to know if that is what is supposed to happen or it's a bug, it doesn't sound right.

At unload, the form is removed from the Servoy cache.
So next time it is loaded again, Servoy will load the form from it's blueprint (the designtime forms)
For your cloned forms these are the forms as you cloned them using the solutionModel.
Any changes you did at runtime will NOT be stageful (but I consider this to be common knowledge to any Servoy developer)
As you didn't change the default tabpanels using the solutionModel (making it designtime properties), the tabpanels will be the original ones.
So the behaviour you see is 100% expected.

maria.kyselova wrote:Also, I'd like to know how to deal with it. I assume I'll be advised to replace tabs at the cloning stage with solutionModel, but that is how it used to be and we refused that method for a few reasons.

Somehow you already know the nr.1 answer: use the solutionModel to assign the new tabpanels.
An alternative could be: assign a 'onLoad' method to the cloned form which will handle the setup of the tabpanels for you.
To be able to do this you should keep a reference somewhere that knows what the 'cloned tabpanel' is for a particular tabpanel in a particular cloned form.

It's either one of these options, but I think from my answer you can already tell what I'd prefer... :-)
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Unload changes the form structure

Postby maria.kyselova » Tue Nov 25, 2014 1:33 am

mboegem wrote:
maria.kyselova wrote:I would like to know if that is what is supposed to happen or it's a bug, it doesn't sound right.

At unload, the form is removed from the Servoy cache.
So next time it is loaded again, Servoy will load the form from it's blueprint (the designtime forms)
For your cloned forms these are the forms as you cloned them using the solutionModel.
Any changes you did at runtime will NOT be stageful (but I consider this to be common knowledge to any Servoy developer)
As you didn't change the default tabpanels using the solutionModel (making it designtime properties), the tabpanels will be the original ones.
So the behaviour you see is 100% expected.

maria.kyselova wrote:Also, I'd like to know how to deal with it. I assume I'll be advised to replace tabs at the cloning stage with solutionModel, but that is how it used to be and we refused that method for a few reasons.

Somehow you already know the nr.1 answer: use the solutionModel to assign the new tabpanels.
An alternative could be: assign a 'onLoad' method to the cloned form which will handle the setup of the tabpanels for you.
To be able to do this you should keep a reference somewhere that knows what the 'cloned tabpanel' is for a particular tabpanel in a particular cloned form.

It's either one of these options, but I think from my answer you can already tell what I'd prefer... :-)


Thanks Marc.
I figured that would be the answer :) But thanks for the confirmation.
Like I said, the first method will not work for what I want to do, but I'll try the second approach (I have a naming convention in place, so knowing which tabpanel should be where is not a problem).
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Unload changes the form structure

Postby maria.kyselova » Tue Nov 25, 2014 7:41 am

Yep, that worked, Marc. Thanks mate.
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Unload changes the form structure

Postby mboegem » Tue Nov 25, 2014 9:15 am

Nice :-)
B.T.W.: you mentioned cloning the forms. Why don't you use form extension? That way you don't need a full copy and it still behaves the same as your parent form.
Difference here is that it's a more lightweight solution. As the extended forms are running in their own scope, you still have the possibility to change your forms individually.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Unload changes the form structure

Postby maria.kyselova » Fri Nov 28, 2014 7:42 am

mboegem wrote:Nice :-)
B.T.W.: you mentioned cloning the forms. Why don't you use form extension? That way you don't need a full copy and it still behaves the same as your parent form.
Difference here is that it's a more lightweight solution. As the extended forms are running in their own scope, you still have the possibility to change your forms individually.


Let me process it, Marc. That would be a revelation!
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Unload changes the form structure

Postby maria.kyselova » Tue Dec 02, 2014 1:33 am

mboegem wrote:Nice :-)
B.T.W.: you mentioned cloning the forms. Why don't you use form extension? That way you don't need a full copy and it still behaves the same as your parent form.
Difference here is that it's a more lightweight solution. As the extended forms are running in their own scope, you still have the possibility to change your forms individually.


Well, I created a sample solution and it broke from the very beginning.
I have a main form with a button 'Open' that opens a new window.
The new window is made with solutionModel: solutionModel.newForm(name, solutionModel.getForm('baseForm')); - so it extends the base form.

It's all good as long as 'baseForm' has no tabpanels.
If I put a tabpanel on baseForm and open more than one window, the tabpanel is only enabled and visible in the last window that I opened. I understand it's because one can't show the same form more than once on the screen, old rule.

So even if the main form is extended, the tabs are not. Should they be? Am I doing it wrong?
Sample solution attached.
Attachments
testExtendedForms.servoy
(4.52 KiB) Downloaded 255 times
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Unload changes the form structure

Postby mboegem » Tue Dec 02, 2014 1:41 am

maria.kyselova wrote:So even if the main form is extended, the tabs are not. Should they be? Am I doing it wrong?

Like you wrote: same old rules.
It's not a magic function that drops all we've learned before.

Currently you're cloning main form as well as all the tab forms.
That doesn't change when using form-extension.
The only thing I pitched to you was to use extension instead of cloning, because it's a more lightweight solution.
All your other code remains the same.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Unload changes the form structure

Postby Peter de Groot » Tue Dec 02, 2014 9:19 am

Hi,

when I do this

Code: Select all
var $name, $form, $newForm, $win;
$name = '_'+new Date().getSeconds()
$form = solutionModel.getForm('_test');
$newForm   = solutionModel.newForm($name, $form);
$newForm.namedFoundSet   = JSForm.SEPARATE_FOUNDSET;
   
$win   = application.createWindow($name, JSWindow.WINDOW);
$win.show($name);


I can open the base form as many times as I like

2014-12-02_0817.png
2014-12-02_0817.png (67.4 KiB) Viewed 6646 times


Regards,

Peter
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Unload changes the form structure

Postby maria.kyselova » Wed Dec 03, 2014 3:31 am

Peter de Groot wrote:Hi,

when I do this

Code: Select all
var $name, $form, $newForm, $win;
$name = '_'+new Date().getSeconds()
$form = solutionModel.getForm('_test');
$newForm   = solutionModel.newForm($name, $form);
$newForm.namedFoundSet   = JSForm.SEPARATE_FOUNDSET;
   
$win   = application.createWindow($name, JSWindow.WINDOW);
$win.show($name);


I can open the base form as many times as I like

2014-12-02_0817.png


Regards,

Peter


I know right!
I can't use separate foundset though, all of my forms are related to each other.
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 7 guests

cron