TMS XData 4.2 Full Source: How to Create REST/JSON Servers with Delphi
mertuahetarImproved: DTO validation messages now inform the full path of the property causing the error. For example, instead of "field name must be required", it shows "field country.name must be required", or "field customers[1].country.name must be required".
TMS XData 4.2 Full Source
Download File: https://urlcod.com/2vK5ok
New: OpenAPI Importer is removed and became OpenAPI Delphi Generator, which is now open source: -dev/openapi-delphi-generator. The generated client is now not dependant on TMS BIZ anymore. Please follow the OpenAPI Delphi Generator repository for updates and upcoming features.New:XData server now returns a xdata-version header in each request.This will make it easier to tell theavailable features of the XData server being connected to. Currentversion returned is 2.Improved:It's now possible to send blobs in JSON using format"Photo@xdata.proxy": "Customers(1)/Photo", even for blobs notflagged as lazy. In previous versions, this was only possible for lazyblobs.Sending such values will simply not modify the blob value in the server.New:XData Music Web Application demo.A complete web application example using a TMS XData server with TMS WebCore as web front-end. Full source code is provided, and the onlineversion of the demo is available at2 Introduction 212.1 Required licenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2 Downloading the source code . . . . . . . . . . . . . . . . . . . . . . 232.3 Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.4 Typesetting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.4.1 Screenshots . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.4.2 Source code . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.4.3 Keyboard and mouse . . . . . . . . . . . . . . . . . . . . . . 262.4.4 References to other books . . . . . . . . . . . . . . . . . . . 262.5 Getting help reproducing the examples . . . . . . . . . . . . . . . . . 26
4 TDBAdvGrid: Data-aware TAdvStringGrid 1654.1 How is data linked to the grid? . . . . . . . . . . . . . . . . . . . . . 1694.1.1 Assigning the datasource . . . . . . . . . . . . . . . . . . . . 1694.1.2 Defining columns . . . . . . . . . . . . . . . . . . . . . . . . 1694.2 PageMode is key! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1704.3 EditPostMode determines when data is posted . . . . . . . . . . . . . 171
5 Assorted grid examples 1755.1 VCL: Loading big CSV data files asynchronously . . . . . . . . . . . . 1755.1.1 Downloading the data . . . . . . . . . . . . . . . . . . . . . 1765.1.2 Why we use a resource . . . . . . . . . . . . . . . . . . . . . 1785.1.3 Adding the resource . . . . . . . . . . . . . . . . . . . . . . 1805.1.4 Loading the resource at run-time . . . . . . . . . . . . . . . 1845.1.5 Indicating activity . . . . . . . . . . . . . . . . . . . . . . . 1865.1.6 Loading data asynchronously . . . . . . . . . . . . . . . . . 1885.2 Browsing data from an SQLite database . . . . . . . . . . . . . . . . 1955.2.1 Creating an SQLite database with Array DML . . . . . . . . 1965.2.2 Changing the browser app to SQLite . . . . . . . . . . . . . 2025.3 Browsing data with a filter . . . . . . . . . . . . . . . . . . . . . . . . 2085.3.1 Populating the combo box . . . . . . . . . . . . . . . . . . . 2105.3.2 Showing only data for one state . . . . . . . . . . . . . . . . 2115.3.3 Initializing the user interface . . . . . . . . . . . . . . . . . 2115.3.4 Loading data for a state . . . . . . . . . . . . . . . . . . . . 2145.3.5 Adding eye candy . . . . . . . . . . . . . . . . . . . . . . . . 2165.4 Using vector images in TAdvStringGrid . . . . . . . . . . . . . . . . . 2175.4.1 Components on the main form . . . . . . . . . . . . . . . . 2195.4.2 Application Settings . . . . . . . . . . . . . . . . . . . . . . 2275.4.3 TIconItem: Container for icons . . . . . . . . . . . . . . . . 2305.4.4 Fields and properties of the main form . . . . . . . . . . . . 2315.4.5 Setting up the grid . . . . . . . . . . . . . . . . . . . . . . . 2345.4.6 Folder selection . . . . . . . . . . . . . . . . . . . . . . . . . 2385.4.7 Updating the image list . . . . . . . . . . . . . . . . . . . . 2395.4.8 Loading icons from a folder . . . . . . . . . . . . . . . . . . 2405.4.9 Loading icons stored in a ZIP archive . . . . . . . . . . . . . 2425.4.10 Export to Microsoft Excel . . . . . . . . . . . . . . . . . . . 2455.4.11 Reacting to display resolution changes . . . . . . . . . . . . 2476 Multi-tier, cross-platform development 2496.1 Building the database . . . . . . . . . . . . . . . . . . . . . . . . . . 2516.1.1 Creating the database . . . . . . . . . . . . . . . . . . . . . 2526.1.2 Postal code table . . . . . . . . . . . . . . . . . . . . . . . . 2546.1.2.1 Source . . . . . . . . . . . . . . . . . . . . . . . . . 2546.1.2.2 Usage restrictions . . . . . . . . . . . . . . . . . . . 2546.1.2.3 Attributes . . . . . . . . . . . . . . . . . . . . . . . . 2566.1.2.4 Creating the table . . . . . . . . . . . . . . . . . . . 2566.1.2.5 Sample data . . . . . . . . . . . . . . . . . . . . . . 2576.1.3 Country codes . . . . . . . . . . . . . . . . . . . . . . . . . 2576.1.3.1 Source . . . . . . . . . . . . . . . . . . . . . . . . . 2586.1.3.2 Usage restrictions . . . . . . . . . . . . . . . . . . . 2586.1.3.3 Attributes . . . . . . . . . . . . . . . . . . . . . . . . 2586.1.3.4 Creating the table . . . . . . . . . . . . . . . . . . . 2586.1.3.5 Sample data . . . . . . . . . . . . . . . . . . . . . . 2606.2 TMS XData: Web services . . . . . . . . . . . . . . . . . . . . . . . . 2606.2.1 Creating the server application . . . . . . . . . . . . . . . . 2616.2.2 Class for Web service data . . . . . . . . . . . . . . . . . . . 2626.2.3 Database access . . . . . . . . . . . . . . . . . . . . . . . . . 2666.2.4 Providing a connection . . . . . . . . . . . . . . . . . . . . . 2686.2.5 Using the GetConnection method . . . . . . . . . . . . . . . 2716.2.6 Querying the database . . . . . . . . . . . . . . . . . . . . . 2726.2.7 Mandatory units . . . . . . . . . . . . . . . . . . . . . . . . 2756.2.8 Defining the service interface . . . . . . . . . . . . . . . . . 2756.2.9 Implementing the service method . . . . . . . . . . . . . . . 2786.2.10 Database client libraries . . . . . . . . . . . . . . . . . . . . 2806.2.11 Adding a custom route . . . . . . . . . . . . . . . . . . . . . 2826.2.12 Browse your services with Swagger UI . . . . . . . . . . . . 2836.2.13 Adding documentation for Swagger UI . . . . . . . . . . . . 2876.2.13.1 XMLDoc in Delphi . . . . . . . . . . . . . . . . . . . 2926.2.13.2 Swagger-specific tags . . . . . . . . . . . . . . . . . 2926.2.13.3 Excluding methods from Swagger . . . . . . . . . . 2946.3 VCL: Implementing a desktop client for lookup . . . . . . . . . . . . 2956.3.1 Designing the main form . . . . . . . . . . . . . . . . . . . . 2966.3.2 Retrieving data from the Web service . . . . . . . . . . . . . 2986.3.3 Implementing the user events . . . . . . . . . . . . . . . . . 3036.3.4 Customizing the grid control . . . . . . . . . . . . . . . . . 3046.3.5 A word on T(Virtual)ImageList . . . . . . . . . . . . . . . . 3056.4 FMX: Mobile app to lookup postal codes . . . . . . . . . . . . . . . . 3056.4.1 The worst...comes first . . . . . . . . . . . . . . . . . . . . . 3066.4.2 HTTP and HTTPS in Android apps . . . . . . . . . . . . . . 3066.4.3 Building the user interface . . . . . . . . . . . . . . . . . . . 3086.4.4 Retrieving data from the Web service . . . . . . . . . . . . . 3116.5 TMS WEB Core: Web client application . . . . . . . . . . . . . . . . . 3156.5.1 Designing the main form . . . . . . . . . . . . . . . . . . . . 3166.5.2 Connecting to the XData server . . . . . . . . . . . . . . . . 3186.5.3 Calling the service method . . . . . . . . . . . . . . . . . . . 3186.5.4 Processing the result and updating the grid . . . . . . . . . 3196.6 VCL: Using the Web service for efficient data entry . . . . . . . . . . 3236.6.1 Designing the user interface . . . . . . . . . . . . . . . . . . 3256.6.2 Fields and constants in the form . . . . . . . . . . . . . . . 3256.6.3 Initializing the form and grid . . . . . . . . . . . . . . . . . 3276.6.4 Saving and loading the grid values . . . . . . . . . . . . . . 3286.6.5 Setup for editing . . . . . . . . . . . . . . . . . . . . . . . . 3296.6.6 Retrieving data from the Web service . . . . . . . . . . . . . 3316.6.7 Evaluating the size of Web service results . . . . . . . . . . 3326.6.8 Validation of postal codes . . . . . . . . . . . . . . . . . . . 3376.6.9 Selection from a combo box . . . . . . . . . . . . . . . . . . 3386.7 TMS XData: Deployment as Windows service . . . . . . . . . . . . . 3406.7.1 Windows application vs. Windows service . . . . . . . . . . 3416.7.2 Migrating an existing serv