Reusing Widgets
Reusing Widgets
CDP Studio supports reusing widgets via libraries and scratchpad. Libraries often make sense if you want to create a reusable interface for underlying components in your library. For more information about scratchpad, see Scratchpad.
How to Store a Widget in a Library
Whenever a library project is opened, the Design mode widget box is populated with the library category where you can manage the widgets stored in a library. To add a widget to a library, just drag from the form editor and drop it on the library category. For each widget, a *.ui file is created under the library project. Once the library is deployed, the widget box is populated even when the library is closed, making it possible to use the widgets but not manage them.
How to Use a Widget from a Library
Deploy a library to ensure resources are available even when the library is not open. To reuse a widget from a library, simply drag it from the widget box and drop it on the form editor. You will notice the resulting widget is wrapped into a CDPBaseUiLoaderWidget with a uiFileName property referring to the *.ui file in a library. This is because we want to reuse the widget without making a copy of it. So all changes in a library will automatically be available once all dependent applications are redeployed. To be able to make a copy, it is possible to hold down the CTRL key and then drag and drop. Only then, the widget is not wrapped into a CDPBaseUiLoaderWidget, and you are free to make modifications without affecting other applications using the same widget.
Note: Remember to deploy the library! It is very easy to reuse a widget from an open library and then run the application and wonder why the widget didn't load. It is usually because the library was not deployed, thus deployed resources were not copied together with the application.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.