Widget overrides
Overriding a widget allows you to replace the default functionality of an existing widget with your custom implementation.
To override an existing widget, use the
gbc create-widget command as follows:
gbc create-widget customization/customization-project-dir MyEditWidget --base EditWidget --overrideThis
command creates a custom widget with the following functionality:- Automatic Actions:
- The
--overrideoption automatically copies the HTML template from the original widget, EditWidget.tpl.html. - It registers the custom widget in the JavaScript file MyEditWidget.js with
the line:
cls.WidgetFactory.registerBuilder('EditWidget', cls.MyEditWidget), replacing the original registration.
- The
- Inheritance:
MyEditWidgetinherits features fromEditWidget.- You can add new features or override inherited ones in the JavaScript file, MyEditWidget.js.
- Replacement: Any instance of
EditWidgetin your program will be replaced byMyEditWidget.
For an example overriding the ButtonWidget, go to Example widget overrides.