Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 6 of 6 total |
Elusive TServerRequest |
Fri, Apr 12 2013 12:02 PM | Permanent Link |
Glenn Mc Library Concepts | The concept of TServerRequest just seems to elude me. I can retrieve the single-row data using the "Database.Load" and "Dataset.Find" methods. But, with several large datasets, the Load process takes too long, especially when only one or two rows are needed.
So, my goal is to find and retrieve a single Row from a data file on a server. I'm running EBW server. MyForm1 includes a TServerRequest component and the following code, modified from the EWB Manual: **** procedure MyForm1.RequestComplete(Request: TServerRequest); begin if (Request.StatusCode=200) then Memo1.Lines := Request.ResponseContent else raise EError.Create('Response: '+Request.StatusText + ' ' + IntToStr (Request.StatusCode)); end; procedure MyForm1.Button1Click(Sender: TObject); begin with ServerRequest1 do begin URL:='/datasets/Copies' ; Method := rmGET ; Params.Add ('method=info') ; //Params.Add ('ItemNum=16') ; ResponseContent.LineSeparator:=#10; OnComplete:=RequestComplete(ServerRequest1); Execute; end ; **** Observations: 1) The result with the code shown is always an 'Error 400.' 2) If I replace the "Params.Add ('method=info')" with "Params.Add ('method=columns')" or "Params.Add ('method=rows')", I get the column and rows lists in JSON format as expected. So what else do I need to extract a single-row result from the server? Is TServerRequest the preferred component/process for this activity? Thanks. |
Sun, Apr 14 2013 12:59 AM | Permanent Link |
Raul Team Elevate | On 4/12/2013 12:02 PM, Glenn Mc wrote:
> The concept of TServerRequest just seems to elude me. I can retrieve the single-row data using the "Database.Load" and "Dataset.Find" methods. But, with several large datasets, the Load process takes too long, especially when only one or two rows are needed. The TServerRequest is basically a wrapper Javascript XMLHttoRequest. It can be used to send http requests to server and handle the response. For example f you have your own back end service (or ewb module) you'd use TServerRequest still to talk to it. TDataset uses the TServerequest as a transport mechanism if you will. > So, my goal is to find and retrieve a single Row from a data file on a server. I'm running EBW server. MyForm1 includes a TServerRequest component and the following code, modified from the EWB Manual: Assuming you're using the EWB Web Server you need to specify your data source as query type (on Row Source Tab) and make sure your query type includes a default filter statement. I don't think the table row source does any filtering (and hence it ignores your parameters and always returns all rows). http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Creating_Loading_DataSets > Params.Add ('method=info') ; What is method=info and where did it come from? I don't believe it's defined in the default EWB implementation. 1) The result with the code shown is always an 'Error 400.' Likely cause method=info is unknown 2) If I replace the "Params.Add ('method=info')" with "Params.Add ('method=columns')" or "Params.Add ('method=rows')", I get the column and rows lists in JSON format as expected. As it should be > So what else do I need to extract a single-row result from the server? Is TServerRequest the preferred component/process for this activity? Use query as row source. You can always define more than 1 dataset against same table on EWB web server - one to load the whole table and other(s) for filtered view. Raul |
Tue, Apr 16 2013 6:06 PM | Permanent Link |
Glenn Mc Library Concepts | Thank you, Raul, for your response. I think, at least, I am now working in the right direction.
>> What is 'method=info' and where did it come from? I don't believe it's defined in the default EWB implementation. It was used in both examples in the manual's Executing a Server Request article: http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Executing_Request Does the documentation contain a list of the supported "method=xxxxx" choices? (So far I've only discovered "columns" and "rows".) >>> Use query as row source. You can always define more than 1 dataset against same table on EWB web server - one to load the whole table and other(s) for filtered view. I have successfully created a SingleItem dataset using the QUERY: SELECT * FROM Cn2Item WHERE {ItemNum=0} (Cn2Item is the DBISAM file name.) The "Database.Load (SingleItem)" procedure runs without errors and fires the AfterLoad event. The SingleItem.RowCount is 0. But even including the following lines before the Load procedure: SingleItem.Params.Add ('ItemNum=2') ; SingleItem.Params.Add ('method=rows') ; the RowCount remains 0. Am I using the wrong code to override the deault value of the SingleItem QUERY? Thanks again for your help. Glenn Mc |
Wed, Apr 17 2013 9:30 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Glenn,
<< It was used in both examples in the manual's Executing a Server Request article: http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Executing_Request >> That's for doing *custom* server requests, not for datasets. That example shows how to retrieve information from the web server back-end application in key-value pair format. Dataset information is handled as JSON. IOW, it you're trying to deal with datasets, then you should stick with the Database.Load method and let the dataset code handle the TServerRequest execution for you. << Does the documentation contain a list of the supported "method=xxxxx" choices? >> The "method" naming is just a name for a parameter and the naming is completely up to you. To avoid confusion with the built-in dataset handling, though, you should probably stay away from using the same names as used with the datasets ("method=commit" and "method=rows"). << The "Database.Load (SingleItem)" procedure runs without errors and fires the AfterLoad event. The SingleItem.RowCount is 0. But even including the following lines before the Load procedure: SingleItem.Params.Add ('ItemNum=2') ; SingleItem.Params.Add ('method=rows') ; the RowCount remains 0. Am I using the wrong code to override the deault value of the SingleItem QUERY? >> You don't need the "method=rows" parameter, that is populated for you by the dataset code. You only need the "ItemNum=2" parameter. If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Thu, Apr 18 2013 9:49 AM | Permanent Link |
Glenn Mc Library Concepts | Tim and Raul,
Thank you, It is all working fine now. I just needed a little help to clear up my confusion. It makes much better sense now. And, getting the "Row Source" SQL correctly entered seemed to make a difference, too Glenn Mc |
Thu, Apr 18 2013 3:30 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Glenn,
<< Thank you, It is all working fine now. >> Fantastic. If you have any other issues, just let us know. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |