Page 1 of 1

Execute JSMethod

PostPosted: Fri Jul 10, 2009 4:50 pm
by martinh
Is it possible to add an execute method to the JSMethod object?

JSMethod.execute( array of arguments)

I would like to use it for the following reason:

I want to make changes to my form using the solutionmodel
I noticed when I add this coding in the onLoad trigger of the form, that this is too late; the changes made by the solution model are not accepted.

So I need to make these changes before load (on load of the solution)
But I also want to use a form method to make these changes.

So if there is a onPreLoad method on my form, I want to execute this:

Code: Select all
   var _form_array = forms.allnames;
   var _form
   var _js_form
   var _preload_method
   
   for (var i = 0; i < _form_array.length; i++)
   {
      _form = _form_array[i]
      
      _js_form = solutionModel.getForm(_form)
      _preload_method = _js_form.getFormMethod('onPreLoad')
      
      if (_preload_method)
      {      
         forms[_form].onPreLoad();
      }
   }



The problem is, that the form itself is also loaded. So if the

forms[_form].onPreLoad();

could be replaced by

_preload_method.execute();

and the form is not loaded when executing this method, then it would wonderful.

I know I could make these onPreLoad methods globals, but I want it to keep with my forms.

Can this be realised?

Martin

Re: Execute JSMethod

PostPosted: Fri Jul 10, 2009 10:14 pm
by mboegem
Hi Martin,

everything you 'touch' with a connection to a certain form, will cause this particular form to load.
So even if executing this method could be done the way you describe (and I'm not aware of something like this) it will load the form.

This is also one of the reasons that we started to use '_methods' forms. These are not really forms in the way of UI, but placeholders for code that concern a certain group of forms.
For example: you could have a bunch of forms that will have everything todo with appointments.
We described the forms like: 'Appointment_dtl', 'Appointment_tbl', but also 'Appointment_methods'. The actual code for 'onPostNewRecord' will be in the '_methods' form. The '_dtl' and '_tbl' forms can also have an 'onPostNewRecord' method which will just call the '_methods' method with passing arguments like triggerform/elementname.

Hope this idea can help you out.

Re: Execute JSMethod

PostPosted: Tue Jul 14, 2009 3:26 pm
by jcompagner
martin,

what you want is impossible that is mixing of runtime with the solution model which isnt supported.

you cant have a form method that alters its own form.

you have to use what is described above, use a empty form that is just used s a scope for methods
something like solutionModifierForm

that has the methods you want to alter the form.