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 --override
This command creates a custom widget with the following functionality:
  • Automatic Actions:
    • The --override option 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.
  • Inheritance:
    • MyEditWidget inherits features from EditWidget.
    • You can add new features or override inherited ones in the JavaScript file, MyEditWidget.js.
  • Replacement: Any instance of EditWidget in your program will be replaced by MyEditWidget.

For an example overriding the ButtonWidget, go to Example widget overrides.