RAD Server CRUD Procedures – Part 3
In this RAD Server CRUD Procedures – Part 3 post we will show how to implement a FireMonkey (FMX) Client to call the RAD Server CRUD procedures and interact with the Employee Table. In the part 2 post, we discussed modifying the default generated CRUD procedure implementations from the RAD Server Package Wizard, to show one possible way to implement Get, GetItem, Post, Put and Delete. In the part 1 post, we discussed the the default generated CRUD procedure implementations from the RAD Server Package Wizard. The Embarcadero RAD Server (also known as EMS – Enterprise Mobility Server) uses the industry standards of REST, and to transfer data to and from the RAD Server REST Service, JSON – JavaScript Object Notation, is typically used as the transfer encoding. Due to the Embarcadero RAD Server supporting industry standard REST and JSON, we will use Delphi’s, C++ Builder and/or RAD Studio’s REST Client Library components (TRESTClient, TRESTRequest, and TRESTResponse ) to implement our EMS REST Client. And recall from Post 2, we used the System.JSON Classes (TJSONArray and TJSONObject) on the back-end RAD Server to implement our CRUD procedures. Employees REST Client For our main REST Client UI form, we have all of the ten (10) columns (fields) from our Employee Table, mostly as TEdit controls for First Name, Last Name, etc., and TSpinBox for the Employee Number, Department Number, and Salary, and one TDateEdit for the HireDate: The bottom panel has 10 TButtons. These buttons will perform the following functions from our RAD Server CRUD procedures:READ: performs the REST HTTP GET, to return all records from the Employee table.PREV: Displays the previous record.NEXT: Displays the next record.FIRST: Displays the first record.LAST: Displays the last record.CREATE: Starts the create mode, to allow the user to use the form to enter a new record.COMMIT: The commit button gets enabled by the CREATE button, and this COMMIT button makes the REST HTTP POST call to the RAD Server to INSERT a new record into the Employee table.EDIT: Starts the Edit mode for the UI form, similar to how Create enter a create mode, allow the user to edit a record.UPDATE: The update button gets enabled by the EDIT button, and after we have made edits to the record, this Update button makes the REST HTTP PUT call to the RAD Server to UPDATE this existing record in the Employee table.DELETE: This Delete button, let’s us delete the current EMP_NO from the Employee table, by making the REST HTTP DELETE call to the RAD Server to DELETE this EMP_NO from the Employee table. With the COMMIT and UPDATE buttons, we do perform their REST calls, and then we perform another GET (READ) call, to get all of the records again. This was just done just for simplicity reasons. This REST Client application also uses the REST Client Library components; RESTClient, RESTRequest and RESTResponse: The Embarcadero REST Client Library is a framework for accessing REST-based web services, like the Embarcadero RAD (EMS) Server. The library is available for all platforms that are supported by Delphi and/or C++ Builder The REST Client Library framework focuses on JSON as the representation format. Let’s now take a look at the implementation code for this Employees REST Client. READ (GET) The source code for the READ (Get) button is this: […]
