Access your component classes from your host project

Components can now publish classes! And even better, if your application is still in binary mode, you can now benefit from classes and object-oriented development by using a component (in project mode) to create your own classes and use them from your (binary mode based) application.

A 4D component is a set of methods and forms. As of 4D v19 R5, it is also a group of classes representing one or more functionalities that can be installed in different applications. The code editor’s completion system and other help systems have been updated to support your components’ classes and methods to make your coding smoother.

Component namespace

You can make your classes usable in your host project by adding a namespace in your component settings when you generate your component. For the internal classes you want to hide in your host project, just prefix their names with an underscore (“_”).

To avoid naming conflicts with existing classes in the host database, you need to create a namespace for your component. In the class store, all your classes will be accessible through this namespace:

New options have been added in the Settings window to make it happen. You can define the namespace for your class, and decide if you want to generate the syntax file to enable auto-completion when a developer uses your component:


After generating your component as usual, and putting it in your host database, you can write this type of code to use your class:

var $class : cs.myComponent.Class1


Completions and tips

When compiled, you can choose to activate the completion and the prototype displaying in the host base by setting the Generate syntax file for code completion option.

If the option is selected, you can use your component’s classes and methods with:

  • Completion:


  • Tips:


  • And prototype at the bottom of the code editor windows:


Take a look at the documentation for more information, and don’t hesitate to give us feedback on the 4D forum!

Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.