Solution Model - extendsForm

Hi

I am trying to create a new form using the SOM based on the template form. For some reason this does not seem to be working and I am wondering if its a bug in Servoy OR my misunderstanding of the notes.

The code example is:

var subForm = solutionModel.newForm(‘childForm’,‘myServer’,‘myTable’,null,true,800,600);
var superForm = solutionModel.newForm(‘childForm’,‘myServer’,‘myTable’,null,true,800,600);
subForm.extendsForm = superForm;

I am subForm is the form your wishing to extend and superForm is the template you want subForm based on. SO:

var subForm = solutionModel.newForm(‘myNewForm’,‘muServer’,‘myTable’,null,true,800,600);
var superForm = forms.template_form
subForm.extendsForm = superForm;

Having tried this all ways I can think of superForm makes no difference to myNewForm which is created correctly but has no features. I would note that template_form has been used extensively throughout the app to extend functionality to other forms in the solution, so generally it works !

Thanks in anticipation

Gordon

Hi Gordon,

The property ‘extendsForm’ takes a string (i.e. the form name), not a form object.

Hi Robert

Thanks, that fixed the problem completely :)

Cheers
Gordon

thats not completely true,

it does take a string yes, but it also takes a JSForm (solution model!) object.
But not a runtime object like: forms.myform!

if you want to do this:

var subForm = solutionModel.newForm(‘myNewForm’,‘muServer’,‘myTable’,null,true,800,600);
var superForm = forms.template_form
subForm.extendsForm = superForm;

then you need to really do this:

var subForm = solutionModel.newForm(‘myNewForm’,‘muServer’,‘myTable’,null,true,800,600);
subForm.extendsForm = solutionModel.getForm(“template_form”);

if you want to go to the solution model itself, ofcourse in this example it is quicker to just assign the string to it.

jcompagner:
thats not completely true,

it does take a string yes, but it also takes a JSForm (solution model!) object.
But not a runtime object like: forms.myform!

if you want to do this:

var subForm = solutionModel.newForm(‘myNewForm’,‘muServer’,‘myTable’,null,true,800,600);
var superForm = forms.template_form
subForm.extendsForm = superForm;

then you need to really do this:

var subForm = solutionModel.newForm(‘myNewForm’,‘muServer’,‘myTable’,null,true,800,600);
subForm.extendsForm = solutionModel.getForm(“template_form”);

if you want to go to the solution model itself, ofcourse in this example it is quicker to just assign the string to it.

So essentially:

  1. you can not amend an existing runtime form using the solution model

  2. you can however clone an existing form and then add features to the cloned form using the solution model

  3. effectively the runtime and solution models co exist but are not interchangeable.

  4. once a form has been created by the solution model and rendered to the screen you can not make changes to it after the fact.

Cheers
Gordon

Hi Gordon,

Gordon:

  1. you can not amend an existing runtime form using the solution model

Sure you can. Just get the JSForm object via solutionModel.getForm(formName) and alter it. At the end you call forms.formName.controller.recreateUI() and you are done.

Gordon:
2) you can however clone an existing form and then add features to the cloned form using the solution model

Yes, you can do this but like explained in point 1 it’s not the only way.

Gordon:
3) effectively the runtime and solution models co exist but are not interchangeable.

Not true, see answer point 1.

Gordon:
4) once a form has been created by the solution model and rendered to the screen you can not make changes to it after the fact.

Yes you can. But OR you make sure the form is no longer displayed when you call solutionModel.removeForm() which destroys the form in memory OR you don’t destroy the form and call controller.recreateUI() after your changes. This last approach doesn’t require you to not display the form.

Hope this helps

Brilliant - that makes a great deal of sense. I did not see any of these points in the WIKI and I think this would be a great addition. Thanks very much for you help guys - good to clarify understanding and learn this stuff

Gordon

One limitation to note with the solutionModel + recreateUI() route is that you cannot alter the datasource and call recreateUI() - as the name implies you can alter the UI, not the data this UI is build on.