form load quirkiness

I have several custom controllers dividing up sections of my application. When I load a particular controller, I have a method attached to the controller’s onshow property that in turn shows another form (which should then load to the right of the controller).

What happens is that the form to the right of the controller shows briefly and then disappears leaving just the controller showing.

I’m on 1.1 on OS X – not sure if how this is a problem on the recent betas.

  • david

The main form defines a controller (NOT the other way arround) by setting the controller property on that form.
In the controller form load you should not show any form…becouse it is loaded/showing as result of a main form show.

Here’s more detail: I am finding it very useful to have my application divided into four different sections – each with their own controller that has navigation buttons to the tables included in that section. To navigate between the sections, I have a global field with a pull down list of the four sections on each controller. The global field has a method triggered onChange that loads a different controller depending on the value in the global field.

This way of using the controller to load a new controller leaves a blank form to the right of the controller. I would like to add one more step to the onChange method that loads an initial form after the new controller is loaded. When I do this, the form loads briefly and then disappears. This is not a huge big deal because the user can just click on the navigation buttons on the new controller to bring up the forms for that controller. However, it would be nice though to bring up an initial default form each time a new controller is loaded.

Sorry for doing things in unexpected ways. It does work pretty good though :)

  • david

I have one question.. How do you load another controller???
can you give me some scripts/examples how you do this?

Because this is not possible, You can’t load a controller. You can only load a form.

Hehe. I have four controllers, one global field with a value list on each controller, and this script attached to the onChange property of the global field:

if (globals.current_app_section == “Website”)
{
forms.controller_website.controller.show();
}
else if (globals.current_app_section == “Application”)
{
forms.controller_application.controller.show();
}
else if (globals.current_app_section == “Recruiting”)
{
forms.controller_recruiting.controller.show();
}
else if (globals.current_app_section == “Sales”)
{
forms.controller_sales.controller.show();
}

BTW, is there a case statement equivelent in JavaScript?

  • david

OK what you do here:

forms.controller_website.controller.show();

is that you are showing the “controller_website” form as the Main form.
You don’t show that “controller_website” as a controller if you call that function.

The “controller” word in that has nothing to do with the controller property of a form.

If i got youre problem right then what you should do is this:

Posted: Mon Sep 29, 2003 9:43 pm Post subject:


Hehe. I have four controllers, one global field with a value list on each controller, and this script attached to the onChange property of the global field:

if (globals.current_app_section == “Website”)
{
forms.website_form.controller.show();
}

and that website_form had the controller_website form as its controller (the form property in designer)

Then you say too servoy show the website_form at the right side and it wil automaticaly show the controller_website as the controller. (on the left side)

(1) Sorry, what I posted is what I am currently doing and you are correct, it does not load anything but the controller:

if (globals.current_app_section == “Website”)
{
forms.controller_website.controller.show();
}

The additional step is that I want to add this to the onShow property of the controller:

forms.website_form.controller.show();

The problem is that the form briefly shows and then disappears. But if you click a button that is on the controller with this method, the form of course appears. It just doesn’t work correctly when the method is attached to the onShow property of the controller.

(2) I tried your method first actually when 1.1 first came out and then agaub with the recent OS X Java update. The problem with it is that the controller does not load properly. In the window menu, the form has a check mark next to it but the controller to the form is not loaded. At this point, if you select the form manually from the window menu, the controller loads.

if (globals.current_app_section == “Website”)
{
forms.website_form.controller.show();
}

I actually have run into a number of controller/form loading issues on the mac and it comes quite naturally now to work around them. Most have been fixed with each release and the Java update – this is the last issue that I am aware of.

(3) Summary: at this point then, the only reliable way to get the new controller to load is to call it directly. If you add a method to the onShow property of a controller that shows a form, the form loads briefly and then disappears.

This is 1.1 on a mac. Let me load a beta up and see if it works differently.

  • david

Again.. you don’t load the controller form if you do this:

if (globals.current_app_section == “Website”)
{
forms.controller_website.controller.show();
}

You just load that FORM and if you then do this in the onShow of the controller_website form:

forms.website_form.controller.show();

the only thing you do is that you first try to load the form controller_website and then in the onShow of that one you are trying to show suddenly another form called: website_form this is just bad programming. You shouldn’t do this, it doesn’t make sense to show another form in the onShow event of a form.

Again, you NEVER CAN load/show controllers (the thing you see on the left side) through javascript. You can only show/load forms what you see on the right side.

Ah, you are correct. Little snafu on my part. I will always do it your way from now on without doubts or questions :)

Thanks for the generous use of your time. - david

Well, yesterday it was working and today it is not. I thought I was going nuts yesterday because the day before it wasn’t working either. :)

There is a bug with your method. A form’s custom controller doesn’t always load with the form leaving the previous controller still visible with the new form (not good). As far as I can tell, it happens when a button on controller_1 shows a form that has controller_2.

So bad programming or not, at the moment the only reliable way to make sure the controller I want to appear is to show it directly.

Servoy 1.1 on OS X

  • david

If you have a solution for me that does that what you describe, please send it over with a short description, because that looks like a bug.

The controller (form) of one (real) form should always be updated when you load a form. If that isn’t the case then it is just a bug.

Example solution attached.

  • david

Ok i found the bug, it is fixed in the release after 1.2RC5

Can I have fries with that? :lol:

Many, many thanks for your responsiveness.

  • david