On Pre Load Form Event

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

On Pre Load Form Event

Postby juliaaano » Thu Apr 15, 2010 9:13 am

Could it be possible to Servoy implement a form event executed every time right before the form is loaded? This method could be called onPreLoad().

We need to dynamically rebuild a form at runtime and we cannot play with the solution model after the form is loaded. Ideally we want to place this code in a base form and it would be executed on demand when the forms extending this guy are loaded. We cannot do this on the onLoad due to existing restrictions, so if we had the onPreLoad it would help a lot.

Thank you.
Juliano Mohr
Information Analyst
The Service Manager (TSM)
Email: jmohr@theservicemanager.com
Website: http://www.theservicemanager.com
juliaaano
 
Posts: 66
Joined: Wed Apr 01, 2009 2:00 am
Location: Australia

Re: On Pre Load Form Event

Postby mboegem » Thu Apr 15, 2010 9:32 am

I don't think this will be possible considering the way Servoy handles forms currently.
Just calling 'forms.myForm' is enough to have the 'onLoad' event already triggered.

I'd say this is a bad horse to place your bet on.

Looking at other possibilities:
Can't you just alter your forms at startup?
We do this all the time for about a 1000 forms and the solutionModel is so fast, it is barely noticed this is executed...

Other thing to investigate:
you do mention this 'super' form to be extended: I'd say once a form which does extend the 'super' form is loaded, you can't alter the 'super' form with the solutionModel anymore.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1524
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: On Pre Load Form Event

Postby lwjwillemsen » Thu Apr 15, 2010 9:36 am

+1 for me. Even better would it be if all the SolutionModel functionality could be done when the form is already shown through form-properties and element-properties.

We were used to that (for 90 %) in Visual (Dynamic) Foxpro. Today in Servoy it's like 70 % can be done at form show time and 30 % at SolutionModel time.

Regards,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 626
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

Re: On Pre Load Form Event

Postby jcompagner » Thu Apr 15, 2010 9:39 am

So you want an event before the form is created?
Where should that event run it? You can't expect then ofcourse stuff from that form (like dataproviders or elements, foundsets)

So it is more a global event (on the solution) that is run in the global scope and called when a form is about to be created?
What would you exactly do in such an event? You want to then apply solution model changes so that you dont have to do that up front?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8212
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: On Pre Load Form Event

Postby pbakker » Thu Apr 15, 2010 10:19 am

We need to dynamically rebuild a form at runtime and we cannot play with the solution model after the form is loaded


You can alter the form and call controller.recreateUI() afterwards.

What kind of modifications would you actually try to perform in the onPreLoad, if it would exists? Better to look at what is actually required, then to just look at the suggested feature request.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: On Pre Load Form Event

Postby juliaaano » Fri Apr 16, 2010 1:51 am

First of all, thanks for all feedback.

mboegem wrote:Looking at other possibilities:
Can't you just alter your forms at startup?
We do this all the time for about a 1000 forms and the solutionModel is so fast, it is barely noticed this is executed...

We don't want to do this at startup because it requires database calls in each loop, which would mean also about 1000 remote calls from the client to the server.

lwjwillemsen wrote:+1 for me. Even better would it be if all the SolutionModel functionality could be done when the form is already shown through form-properties and element-properties.

Agree with that. If more things could be done through form and element properties I wouldn't even bother starting this discussion.

jcompagner wrote:So you want an event before the form is created?
Where should that event run it? You can't expect then ofcourse stuff from that form (like dataproviders or elements, foundsets)
What would you exactly do in such an event? You want to then apply solution model changes so that you dont have to do that up front?

I don't see a problem why it couldn't run in the own form with some limitations, i.e. not accessing dataproviders, etc. Or even maybe creating a new object bound to the form for handling only the events.
Yes. I do want to apply solution model changes on demand form by form.

pbakker wrote:You can alter the form and call controller.recreateUI() afterwards.
What kind of modifications would you actually try to perform in the onPreLoad, if it would exists?

We want to modify the form structure based on database settings (database driven forms). It includes among many other things assigning methods to element events (rightClick, etc.).
We can't use the recreateUI because the impossibility to alter the form on the onLoad method, reason why I started this whole discussion suggesting the onPreLoad event.

As a conclusion so far, I still think we could have this feature released. Many Java components have in their life cycle something like a preConstruct or preLoad events.
Juliano Mohr
Information Analyst
The Service Manager (TSM)
Email: jmohr@theservicemanager.com
Website: http://www.theservicemanager.com
juliaaano
 
Posts: 66
Joined: Wed Apr 01, 2009 2:00 am
Location: Australia

Re: On Pre Load Form Event

Postby pbakker » Fri Apr 16, 2010 10:34 am

We can't use the recreateUI because the impossibility to alter the form on the onLoad method


Don't think you're correct here, the sample below works just fine. Attach the onLaod method to the onLoad event handler on a form and start the form in a Client.

Paul

Code: Select all
/**
* Callback method when form is (re)loaded.
*
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"9A0CDBF9-054C-44E5-8EEB-9DEB3983EA89"}
*/
function onLoad(event) {
   var f = solutionModel.getForm(event.getFormName())
   f.onShow = f.getFormMethod('test');
   f.newButton('test button',10,10,100,20,f.getFormMethod('onAction'))
   controller.recreateUI();
   //application.output(f.onShow.code)
}

/**
* @properties={typeid:24,uuid:"6F48DBF8-8640-43DA-8DD2-A731CF8E8E7A"}
*/
function test() {
   application.output('onShow called')
}

/**
* @properties={typeid:24,uuid:"4E6CF106-92C6-401F-B9E6-6626A14A3981"}
*/
function onAction() {
   application.output('This works as well')
}
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: On Pre Load Form Event

Postby juliaaano » Mon Apr 19, 2010 5:46 am

You are absolutely right. With the recreateUI method is possible to change the form through the solutionModel on the onLoad event, allowing us to solve many of our problems.

Thank you. For me this discussion is over.

Cheers,
Juliano Mohr
Information Analyst
The Service Manager (TSM)
Email: jmohr@theservicemanager.com
Website: http://www.theservicemanager.com
juliaaano
 
Posts: 66
Joined: Wed Apr 01, 2009 2:00 am
Location: Australia


Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron