Dear Martin,
Great to see you are working with the new pluggable widget framework. The switch/Boolean slider is not a pluggable widget. It is a (temporary) hybrid widget type, it uses React but not the new API, it will be replaced soon by pluggable widget.
When the flag pluginWidget=”true” is set it will become a plugin widget. Plugin widget are declarative and are not responsible any longer for data retrieval, subscriptions or action execution.
So, when you use an attribute, you will receive the new props whenever they change. Just re-render with the value.
See also tutorial https://docs.mendix.com/howto/extensibility/pluggable-widgets
Reference docs: https://docs.mendix.com/apidocs-mxsdk/apidocs/pluggable-widgets
Cheers, Andries
Hi Martin, thanks for your question. We don't support entities in Pluggable Widgets, because the properties are resolved out -of-the-box for now. You can check the Pluggable Widgets API to clarify your questions and learn a bit more about Pluggable Widgets.
Check it here https://docs.mendix.com/apidocs-mxsdk/apidocs/pluggable-widgets
Hello Martin,
This might be a bit out of date since I’ve not worked with widgets since Mx 6 but we used to declare that the widget requires a context entity in the widget XML, then you’d declare _contextObj in your js which you would then populate on your update call.
XML widget definition:
<widget id="MyWidget.widget.MyWidget" needsEntityContext="true" xmlns="http://www.mendix.com/widget/1.0/">
JS Snippet:
// Internal variables.
_handles: null,
_contextObj: null,
update: function (obj, callback) {
logger.debug(this.id + ".update");
this._contextObj = obj;
this._executeCallback(callback, "_update");
}
Hope this helps