How to subscribe to client refresh in widget.

2
I am currently working on changing the radio button widgets validation functionality so that it works the same as standard Mendix components. What i want to happen is that the validation messages will disappear when the object is refreshed in a microflow. When you do a refresh in mendix all validation messages will currently disapear, apart from the radio button validation messages. I have tried using the javascript subscribe function along with the validation parameters. I have this working when the user clicks the next button. mx.data.subscribe({ guid: mxObject.getGuid(), val: true, callback: function (validations) { if (self.readonly) { validations[0].removeAttribute(self.name); } else { var reason = validations[0].getReasonByAttribute(self.name); if (dojo.query('.alert', this.domNode).length > 0) { dojo.destroy(dojo.query('.alert', this.domNode)[0]); } if(reason){ var div = dojo.create('div', { 'class': 'alert alert-danger' }); mxui.dom.textContent(div, reason); dojo.place(div, self.domNode, 'last'); validations[0].removeAttribute(self.name); } } } }); But this doesn't clear the validation message when the object is refreshed. I don't want this to be triggered when the user enters details in another attribute. If i wanted this i could use the standard subscribe method. What i need is it to be only triggered when there is a microflow refresh of an object. Regards Simon
asked
1 answers
2

You can use the same subscribe method to subscribe to an object, instead of to validations of an object. See the API documentation for examples. Use the subscribe alias on widget to make sure the subscriptions are automatically removed when the widgets is destroyed

answered