Hi, we have a requirement where we need to pull in data provided by a webservice and update the the category attribute values using the same. This needs to be done in SmartUI. Has anyone done this before? Any leads or ideas ?
Hi Sharad,
If it was a Restful API being used to pull the data and update the attributes, it would have been straight forward in Smart UI. If you have a limitation to use th XML(Soap) web service then it gets trickier.
Use a Backbone model and map it a category url to fetch and sync in smart UI through some action or command. If it is Rest API, you can directly call the model's fetch function, edit\modify using UI (probably in a widget or whatever UI component you are using) and then sync it. But if it is a Soap end point, Backbone (internally jQuery) cannot by default receive xml content type or parse the xml . So you need to send additional paramters in Backbone fetch & sync options and also use some library like Jath to convert the xml response to json during parse stage, as your views would not be able to process or use xml response.
I am assuming, you have some expertise about the basic Smart UI extensions like Commands, widgets, Routers and contexts. But if you are struggling with how to implement in Smart UI or what components to be used then go through the samples first before reading the XML complication and the resolution to be used.
Thank you Sai for your response. I have created a backbone model to fetch data from the REST api and you are right, I am trying to see which SmartUI element can I use to implement this functionality
Hello,
Can you share the backbone mode you used to fetch data from a REST API. I have the same need, and i want to avoid starting from a blank page
<!DOCTYPE html><html><head> <meta charset="utf-8" /> <title>customer form</title> <script src="jquery-3.2.1.min.js"></script> <script src="underscore-min.js"></script> <script src="backbone-min.js"></script> </head><body> <div id="customerview"></div> <script> var customer = Backbone.Model.extend({ url: 'https:/..', parse: function (resp) { return resp } }) /* view */ var custView = Backbone.View.extend({ tagName: "div", className: "customerform", events: { }, initialize: function () { this.listenTo(this.model, 'change', this.render); this.model.fetch({ success: function (resp) { console.log(resp) },
error: function () { console.log('error') }, headers: {
'Accept': 'application/json', 'Access-Control-Allow-Origin':'*', 'Access-Control-Allow-Credentials':'true', 'Subscription-Key': 'aaa', 'Authorization': 'aaa' } }) }, render: function () { this.$el.html(JSON.stringify(this.model)) return this; } }) var mycustomerModel = new customer(); var mycustView = new custView({ model: mycustomerModel}) $('div#customerview').append(mycustView.render().el) </script></body></html>