Still in the evaluation phase for the upcoming project I come across this question:
I would like to use XData with Webcore and would like to omit Aurelius like Holger Flick demonstrated in his web series building a XData Server with Firedac driven data services. Is the WebCore dataset compatible with the JSON delivered by Firedac on the server side or do I have to use Aurelius when using this Web-Dataset?
The latter approach is the one you should use and then the JSON can be consumed easily by a TMS Web Core application using TWebClientConnection and TWebClientDataSet.
You do not need one. Just do not provide one. The webclient dataset component on the client side should be smart enough to recognize the data structure.
Right-click the component and select "Fetch fields...". That'll set up everything on the client.
You do not need one. Just do not provide one. The webclient dataset component on the client side should be smart enough to recognize the data structure.
Right-click the component and select "Fetch fields...". That'll set up everything on the client.
[/QUOTE]
trying to follow this approach to get complex sql query's data from my DB I'm able to retrieve a json in the response.result but I'm not able to correctly load it in TXDataWebDataset with setjsondata.
XDataWebDataset1.setjsondata(adata);
XDataWebDataset1.Open;
complete without errors but XDataWebDataset1.recordcount is equal 1 (and I know I've more records) and no fields in fieldslist...
the json has been created as suggested and it seems good... I can't find a way to Fetch fields as you suggested... EntitySetname is required but I've no entities in this case... how fetch fields?
How to consume the json with TXDataWebDataset, is it the right component?
What does your JSON (adata) look like? Maybe the array is surrounded in a JSON object. For the XData dataset, you have to provide a JSON array to it. Inspect adata, maybe you have to cast it to a TJSObject and provide a sub-property to the dataset.
Indeed, XData dataset retrieve fields from its metamodel (entity set), but in this case you can simply manually create the persistent fields at design-time.
and I'm actually able to consume it with a WebLib.JSON objects (JSON, JSONArray, JSONObject),
and it is a good thing... but about using XDataWebDataset I don't understand how I can use it...
OK, I can typecast the Response.result as a TJSObject and parse it in an JSONArray (what I've done to manage programmatically as JSON) but I don't know how to "provide a sub-property to the dataset"...
Tried to create persistent fields at design-time but I've got the error:
ERROR Uncaught TypeError: Cannot read property 'FAttributes' of null | TypeError: Cannot read property 'FAttributes' of null at Object.LoadData
Web Core seems a little "farraginous" for a more than simple web application, dealing with delphi forms/html syncronization looks to me not very fast/productive (but this can be my first impressions)...
Your response looks to be a JSON array. Make sure Response.Result is also a json array, you can output it to console. This way you can see exactly what Response.Result is.
If it's a JSON array, you should simply use SetJsonData(Response.Result) and it should get as many records as items you have in the array.
Then you can create persistent fields indeed, named "id1", "name1", etc., and it should work fine.
About the error you are getting, I cannot reproduce it. Can you please provide the exact steps to reproduce, or send a sample project to our e-mail that reproduces the issue?