Updating Data on the Server

One frequent question about Flash Remoting is, “How do I get the recordset back to the server?” The short answer is that you have to program your Flash movie to manually parse the data and send it to the server. For example, when using the DataGrid component, changes made to the data are not uploaded to the server automatically. In the next few sections, however, I’ll show you a few techniques that can be used to ease the passing of data back to the server.

Passing a Record to the Service Manually

In Chapter 3, you saw a Products display using text fields in Examples Example 3-3 through Example 3-8. The examples added several new properties and methods to the RecordSet class. We’ll expand on that example to show the updating, inserting, and deleting of data. I’ll go through the server-side code first. The component is called ProductsAdmin.cfc and should be saved in the webroot \com\oreilly\frdg\admin folder. As you recall from the previous ColdFusion security discussion, this directory is protected by an Application.cfm file. Therefore, to access the remote methods in this directory, your Flash code must log into the application. For the purposes of the example, the authentication code is hardcoded into the Flash file.

The server-side code

We need these main services:

getSearchResult(search)

Gets a subset of the products, or all products

addProduct(record)

Adds a new product to the Products table

updateProduct(record)

Updates an existing product

deleteProducts( ...

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.