Inheritance
reviewed: 22 February 2025
Inheritance Basics
CaseMaster supports a basic concept of inheritance. A script can inherit form another script as long as some basic rules are adhered to:
- A script can nly inherits from another script that is of the same type (so a bo can inherit from a bo, page can inherit from a page, etc)
- An inheritance tree cannot recursive (a inherits from b which inherits from c which inherits from a again)
- A script cannot inherit from itself (which, one could argue is also a case of recursion)
- A script can have no or one parent; a script can not inherit from multiple parents
How to Define Inheritance
You can inherit form another file by simply adding the inherits directive at the top of a script. Example:
inherits 'base' // Inherits form page/base.cms
function main()
page.render( page.get( './main' ) )
end-function
Examples of Inheritance Use
There are several use cases for inheritance. Some will be explained in more details in other documents.
Inheritance of Pages
Pages are explained in more detail here. A page script has a number of (optional) function with reserved names that server a special purpose.
For example, the reserved function names beginPage, main and endPage have a special meaning in CaseMaster when handling page requests.
The function beginPage can, for example, be used to generate the HTML header of a page including navigation elements such as a menu bar.
In CaseMaster you often find a base.cms page script that implements all such basics in beginPage and endPage. Each page that inherits from base.cms will only have to worry about the main function where the actual content of the page is implemented. The chrome (e.g. menu bar and footer) is handled by base.cms.
Inheritance of Business Objects
Business objects are described in more details here.
Some business objects are part of the runtime (for example user representing a user profile) or come with a specific reusable module. You may however find that you need to add attributes to meet your specific requirements, make a change to an attribute or add functionality to the _eventAction function.
You can create a new business object, inherit from the business object you wish to extend and override and / or add the logic that you require.
Inheritance of Qualifiers
Qualifiers are described in detail here.
Qualifiers can be used for many different purposes but their most prominent us is probably as the building blocks of web pages. Inheriting from a qualifier can be useful when you wish to alter a specific behaviour of an existing qualifier. For example, the qualifier page/subtitle inherits from page/title and overrides the font size.
Accessing Parent Functions
See here.
<End of document>