How to create a service inside a custom widget?
- January 30, 2018
- 1 reply
- 7874 views
I am trying to develop a print widget extension, allowing to print an HTML including a QR code or an image. For that, I need a service called "Print" in my custom widget.
I tried to add the "widgetServices" function in the *.ide.js file:
this.widgetServices = function () {
return {
'Print': { 'warnIfNotBound': false }
};
}
In the *.runtime.js file, I added the function "serviceInvoked":
this.serviceInvoked = function (serviceName) {
if (serviceName === 'Print') {
printJS('div-to-print', 'html');
thisWidget.jqElement.triggerHandler('PrintFinished');
} else {
TW.log.error('Print widget, unexpected serviceName invoked "' + serviceName + '"');
}
};
I join the IDE and RUNTIME JavaScript files, so you can see my whole code.
When I import it in the composer, I can bind an event to the service "Print". However, when I view the mashup, the service is never called. Does someone know how to fix that issue?
Thanks,
Antoine

