# Inherited form methods using SolutionModel

**URL:** <https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137>\
**Category:** Classic Servoy\
**Created:** [May 3, 2010, 12:03pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137 "2010-05-03T12:03:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [May 3, 2010, 12:03pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/1 "2010-05-03T12:03:48Z")

</div>

Hi,

Is the following a bug or is it intended to work like this:

With the SolutionModel I create a new form.  
This new forms shoud inherit the properties of another form.  
This works without problems:

```auto
		var _js_dtl_form = solutionModel.getForm('myForm1')
		if (! _js_dtl_form) // No form found. Quit the function
			return;
		var _js_sea_form = solutionModel.newForm('myForm2', _js_dtl_form.serverName, _js_dtl_form.tableName, _js_dtl_form.styleName, false, _js_dtl_form.getBodyPart().height, _js_dtl_form.width)
		_js_sea_form.extendsForm = _js_dtl_form
		_js_sea_form.useSeparateFoundSet = true

```

The form is shown correctly when I show myForm2.  
But it looks like that the methods are not inherited. I have an globals method on the onShow event on my first form, but I see that this onShow event is not called on my second form.

When I add the following line, it does work:

```auto
		if (_js_dtl_form.onShow)
			_js_sea_form.onShow = _js_dtl_form.onShow;

```

Is this correct or is this an issue?

Martin

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [May 3, 2010, 12:13pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/2 "2010-05-03T12:13:56Z")

</div>

that should work fine, i cant reproduce it in quick example:

```auto
/**
 * Callback method when form is (re)loaded.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"CFC9F108-DAF1-47FD-8F27-220700A418F0"}
 */
function onLoad(event) {
	application.output("onload:" + controller.getName());
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"D2682977-675B-4049-8EDE-2CFB00DACE5F"}
 */
function onShow(firstShow, event) {
application.output("onshow:" + controller.getName());
}

/**
 * @properties={typeid:24,uuid:"DE7E8D42-EF4C-4F3C-A58E-ADFF9DCCDC54"}
 */
function subform()
{
	var form = solutionModel.getForm("Test");
	
	var newForm = solutionModel.newForm("Test2",form.dataSource,null,false,600,400);
	newForm.extendsForm = form;
	
	forms.Test2.controller.show();
	
}

```

those i add to a form “Test” which creates a new form and attach itself to that new form  
then when i show it will display it, this is the complete output:

```auto
onload:Test
onshow:Test
onload:Test2
onshow:Test2

```

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [May 3, 2010, 12:39pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/3 "2010-05-03T12:39:29Z")

</div>

Johan,

There are some differences with your test

1. I’m using 4.1.6
2. I’m using global methods

I did the same as you, but I didn’t get the output  
But after quiting the developer and restarting developer again, it seem to work.  
So it looks like there is some issue in developer that keeps somewhere in memory settings from a previous run  
If I have more details I’ll let you know.

Martin

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [May 3, 2010, 1:21pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/4 "2010-05-03T13:21:31Z")

</div>

global method shouldn’t really be any different then form specific onces.

Maybe there is a bug in 4.1.6, or some other kind of caching that isnt updated.

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [May 3, 2010, 1:22pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/5 "2010-05-03T13:22:31Z")

</div>

yes it looks like that. I’ll try to find it out

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [May 3, 2010, 3:31pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/6 "2010-05-03T15:31:36Z")

</div>

Maybe it is not a bug, but I’m wondering if all goes well.

It looks like the onShow event is not triggered.  
The situation is that the form is shown and then set into find mode in the same script.  
And then the onShow event is not triggered.  
Is that correct behavior?  
Because now I have to execute the onShow method on each place where I expect an onShow event can happen.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [May 3, 2010, 3:34pm UTC](https://forum.servoy.com/t/inherited-form-methods-using-solutionmodel/12137/7 "2010-05-03T15:34:04Z")

</div>

onshow should be called if that a form is made visible

So if you have a sequence of events that you see that onshow isnt triggered let me know.
