Child pages
  • Inheritance Model

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: spelling

Form inheritance is used to extend a form with a other form this 's functions and UI with those of another form (the super form). This will give the original form all the methods/variables/elements/properties/parts of the extending form that it extends.
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. The result is that form c wil will 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 an 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 in runtime, you can use the solution model using the same property.

...

On the child form you will inherit all the methods of the super form. You can overwrite this method, when these methods. When you do this servoy , Servoy will generate a method for you with a call of the to it's 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'.

...

There are not many limitations to form inheritance. One of the limitations is that if you have a  element on an 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 ones, only after new parts can only be added below 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.

...