Page 1 of 1

On Pre Load Form Event

PostPosted: Thu Apr 15, 2010 9:13 am
by juliaaano
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.

Re: On Pre Load Form Event

PostPosted: Thu Apr 15, 2010 9:32 am
by mboegem
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.

Re: On Pre Load Form Event

PostPosted: Thu Apr 15, 2010 9:36 am
by lwjwillemsen
+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,

Re: On Pre Load Form Event

PostPosted: Thu Apr 15, 2010 9:39 am
by jcompagner
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?

Re: On Pre Load Form Event

PostPosted: Thu Apr 15, 2010 10:19 am
by pbakker
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

Re: On Pre Load Form Event

PostPosted: Fri Apr 16, 2010 1:51 am
by juliaaano
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.

Re: On Pre Load Form Event

PostPosted: Fri Apr 16, 2010 10:34 am
by pbakker
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')
}

Re: On Pre Load Form Event

PostPosted: Mon Apr 19, 2010 5:46 am
by juliaaano
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,