I’m kind of confused by the examples of how to use DataSource. Basically, I need a DataSource that supports CRUD operations. I set the URLs for each operation (fetch,add,update,remove) and set the DataUrl to the url same as fetch.
It works fine but if I comment out setDataUrl(…), my list grid doesn’t fetch me the data. Doesn’t datasource.fetch() calls the bound operation of fetch that I specified in setOperationBindings()? Also, when I do “save”, it doesn’t seem like the URL I specified in setOperationBindings() for “update” operation is called…
Is there a better example of how to use operation bindings?
This is taken word for word from the JavaDoc of OperationBinding.setDataURL(String dataURL)
What role does the dataURL in each operation binding take up? If it’s set as the datasource’s dataURL, what are the reasons to have operation bindings?
Could you be more specific? I’ve read the documentation for dataSource.setOperationBindings(). What I want to know is simply why the fetch url is not called when fetchData() is called on a data source.
I believe this example uses RestDataSource, which has set{Fetch,Remove,Update,Add}Url methods. But these methods are not present in the DataSource class.
If you want hands-on, step by step help, training and consulting services are available from Isomorphic Software. Otherwise please show an interval between questions that indicates you are actually trying to make use of the free help we’re providing, ok?
The docs for RestDataSource explain that offers a specific, pre-built protocol for server contact. It’s superclass DataSource is the right starting point adapting to a pre-existing protocol that you can’t change.
OperationBinding has a setDataURL(). RestDataSource.setFetchDataURL() is just a helper method that calls this (see RestDataSource.setDataURL).
But your primary problem is that you’ve setClientOnly(true) on your DataSource, which is doc’d as preventing all server contact.
I was posting the code when your second reply comes so after I posted the code and refreshed the page, I saw your second reply and didn’t think it addresses my original question of why it fetchData() wasn’t called, so I replied it right away…Yes, I studied the showcase code beforehand so I knew that the example you were referring to doesn’t use operation binding explicitly. So I wasn’t trying to take advantage of your time and FREE help and swamp you with uneducated questions (or at least not intentional). Sorry…
The problem is you can bind multiple operation types to a data source (e.g., fetch and update), but you only have one setDataURL() method in DataSource.
If it prevents all server contact, why it works when I do datasource.setDataURL()? I know it’s a premature question (yet again…sorry). I’ll look into that more. Thank you for the pointer.
Because there are multiple operationBindings per DataSource, OperationBinding.setDataURL() gives you a way to set a URL per operationType.
If given a dataURL, a clientOnlyDataSource will contact the server once ever, to load test data. It will then perform all subsequent operations without server contact.
I understand there can be multiple operation bindings per data source. I think I didn’t communicate my question well in the last post, but nonetheless, the following clearly answers my question: