I'm not sure I have this set up correctly.
I have a TXDataWebDataSet and it's linked to my XData connection and a TXDataWebClient (also linked to the same connection. The data is loaded using:
procedure TMyForm.SetPageId(Value: Integer);
procedure OnSuccess(Response: TXDataClientResponse);
begin
PageDataset.SetJsonData(Response.Result);
PageDataset.Open;
end;
begin
FPageId := Value;
PageClient.Get(PageDataset.EntitySetName, '$expand=ARTICLE', Value, @OnSuccess);
end;
and then
procedure TMyForm.PageDatasetAfterOpen(DataSet: TDataSet);
var s: String;
begin
s := PageDatasetARTICLE.Value;
ContentData.Text := s;
end;
ContentData is a RichEdit control. The standard data comes back ok, but the Article (which is a LazyLoaded blob field doesn't.
Is there a way to do a Get from teh dataset instead of using the TXDataWebClient?
Thanks
wlandgraf
(Wagner Landgraf)
2
$expand clause doesn't affect blob fields, only associations. For blob fields you will have to perform an extra GET to get blob content.
Here is an example:
procedure TForm1.WebButton1Click(Sender: TObject);
var
xhr: TJSXmlHttpRequest;
procedure _Load;
begin
WebMemo1.Lines.Text := xhr.responseText;
end;
begin
xhr := TJSXMLHttpRequest.new;
xhr.open('GET',
XDataWebConnection1.URL + '/' +
string(TJSObject(XDataWebDataset1.CurrentData)['ARTICLE@xdata.proxy'])
);
xhr.overrideMimeType('text/plain; charset=utf-16');
xhr.addEventListener('load', @_Load);
xhr.send;
end;
Thanks.
If the text is edited then is it ok to set the Dataset field with the value and just post the dataset?
BTW a TWebDBRichEdit would be nice :-)
wlandgraf
(Wagner Landgraf)
4
Note that with the code above the text is not in Dataset. You are not editing the dataset field.
It's better to also perform a separate PUT request to the same address, with the new content.
Are there an examples fo using TJSXMLHttpRequest? One for each (PUT, DELETE, POST) would be nice. Thanks