Hi there, I am just starting to play with SmartClient, and it's pretty awesome so far! I am integrating it with a Ruby on Rails RESTful backend, and ran into a slight issue. For Rails, the PUT/DELETE controller methods (update/destroy) expect the id to be passed in on the URL instead of a parameter on the query string. SmartClient right now doesn't seem to provide a way to dynamically alter the URL of a DataSource after it's created, so I went ahead and forked RestDataSource to do a little tweak that adds the id to the end of the URL when looking up the url for a PUT/DELETE:
This works, but I'm sure it's not the best way to do it. Perhaps you guys can add a feature to the RestDataSource that allows the user to dynamically inject parameters into the path? For example, I might actually have a RESTful route that is "/libraries/3493/books/39483/author.xml", so I'd probably want to specify the URL to the data source as "/libraries/{library_id}/books/{book_id}/author.xml" so I can change the library_id at runtime to be the library that is bound via a foreign key on the DataSource.
Hope this makes sense, thanks for all the effort put into the framework, it really shows!
Code:
getDataURL : function (dsRequest) { var type = dsRequest.operationType; if (type == "fetch" && this.fetchDataURL != null) return this.fetchDataURL; if (type == "update" && this.updateDataURL != null) return this.updateDataURL + "/" + dsRequest.data.id; if (type == "add" && this.addDataURL != null) return this.addDataURL; if (type == "remove" && this.removeDataURL != null) return this.removeDataURL + "/" + dsRequest.data.id; return this.Super("getDataURL", arguments); },
Hope this makes sense, thanks for all the effort put into the framework, it really shows!
Comment