Child pages
  • Inheritance Model
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

Form inheritance is to extend a form with a other form this will give the original form all the methods/variables/elements/properties/parts of the extending form.
The inheritance is not limited to 1 level, for example if you have form a, form b and form c you can extend form b with a and c with b form c wil then have all the methods/variables/elements/properties/parts of form a, b and c.

Form a:

Form b:

Form c:

Setting a super form

On a existing form you can set the super form by going to the properties and setting the "extends" property to the super form.

If you want to do this runtime you can use the solution model using the same property.

Sample method:

function extending() {
	var _jsForm = solutionModel.getForm('formC')
	_jsForm.extendsForm = solutionModel.getForm('formB')
}

Overwrite methods

On the child form you will inherit all the methods of the super form. You can overwrite this method, when you do this servoy will generate a method for you with a call of the super in it.



In the generated method you will see _super.newRecord(event) this will call the original method on the super form. You can remove this if you don't want to call this method anymore or you can put code before of after the call, if you put it after don't forget to move the 'return'.

Sample of code before:

function newRecord(event) {
	vMode = 'new Record'
	return _super.newRecord(event)
}

Sample of code after:

function newRecord(event) {
	_super.newRecord(event)
	city = 'Amersfoort'
	return
}

Limitations

There are not many limitations to form inheritance. One of the limitations is that if you have a  element on the super form you can not delete it on the child form, if you don't want to see it on your child form you can uncheck the visible property of the element. Another limitation is that you cannot insert new parts in-between existing, only after existing parts.

Inheritance and Security

The security of a form that is extended works like it would work if it was not extended, you can set security on all the elements you see on the form even if they are inherited. You have to set the security on the form the user uses and not on one of the super forms. In the security tab you will see from which form the elements are inherited.

  • No labels