Listing 1

<cfcomponent name="ListingDAO">

<cffunction name="create" output="false" hint="Inserts a new record and returns the primary
 key of the inserted item" access="public" returntype="string">
    <cfargument name="mls_id" required="true" type="string" hint="Primary key"/>
    <cfargument name="address" required="true" type="string" hint="Address"/>
    <cfargument name="city" required="true" type="string" hint="City"/>
    <!--- additional arguments removed  --->

    <cfset var insertListingQuery = "" />

    <cfquery name="insertListingQuery"  datasource="realestate">
INSERT INTO listing
(mls_id, address, city
<!--- additional columns removed  --->
)
        VALUES (
        <cfqueryparam value="#arguments.mls_id#" cfsqltype="CF_SQL_VARCHAR"
		 maxlength="10"/>,
        <cfqueryparam value="#arguments.address#" cfsqltype="CF_SQL_VARCHAR"
		 maxlength="100"/>,
        <cfqueryparam value="#arguments.city#" cfsqltype="CF_SQL_VARCHAR" maxlength="50"/>
        <!--- additional values removed  --->
)
        </cfquery>

        <cfreturn arguments.mls_id>

</cffunction>

<!--- additional functions removed:
    <cffunction name="update" returntype="string">
<cffunction name="remove" returntype="string">
<cffunction name="fetch" returnType="struct">
  --->
</cfcomponent>

Listing 2

<cffunction name="create" access="remote" returntype="struct" output="false"
 description="Creates a property listing">
<cfargument name="mls_id" required="true" type="string" hint="Primary key"/>
    <cfargument name="address" required="true" type="string" hint="Address"/>
    <cfargument name="city" required="true" type="string" hint="City"/>
    <!--- additional arguments removed --->

    <!--- you could also use cfinvoke or access a component in memory --->
    <cfset var listingManager = createObject("component",
	 "realestate.components.ListingDAO")/>

    <cfset var result = structnew()/>

    <!--- insert record --->
    <cfset listingManager.create(argumentCollection=arguments) />

    <!--- retrieve the complete record to show.
    fetch() returns a structure with the query columns as keys
    --->
    <cfset result["item"] = listingManager.fetch(arguments.mls_id) />

    <!--- set successful operation status
    (you should set this status as true or false depending
    on whether the operation was really successful or not)
     --->
    <cfset result["status"] = javacast("boolean", true) />
    <cfreturn result/>

</cffunction>

Listing 3

public function submitEdit():Void {
        //declare an object that will be sent as a structure to the service
    var editArguments = {};

        //to get data contained in Text inputs,
        //textareas and dateFields use myTextInputName.text
    editArguments.address = edit_address.text;
    editArguments.listedOn = edit_listedOn.text;
    editArguments.remarks = edit_remarks.text;

        //to get data from radio buttons,
        //use myRadioButtonName.selectedData
    editArguments.status = edit_status.selectedData;

        //checkboxes store their true/false value in
        //their selected property myCheckboxName.selected
    editArguments.hasPool = edit_hasPool.selected;

        //to get the selected choice in a dropdown,
        //use mySelectName.value or mySelectName.selectedItem.data
    editArguments.state = edit_state.value;

           //run validation
    if( mx.validators.Validator.isStructureValid(this, 'RealEstateAdmin') ){
            //show clock cursor
        mx.managers.CursorManager.setBusyCursor();

            //this is a new record
        if (listingGrid.selectedItem == undefined) {
               //call create service method
            RealEstateAdmin.myGlobalObjects.listingService.create( editArguments);
        }

            //this is an updated record
        else {
                //call update service method
            RealEstateAdmin.myGlobalObjects.listingService.update( editArguments);
        }
    }
}


Listing 4

responseHandler.update_Result = function( results: Object ):Void {
    var item:Object = results.item;
           //find the item's index
    var index:Number = _root.findItem(listingGrid,'mls_id',item.mls_id);

    if (results.status && index >= 0){
listingGrid.replaceItemAt(index,item);

            //show a message
        alert("Item updated");
    }
    else {
               //show a message
        alert("Item could not be updated");
    }

    mx.managers.CursorManager.removeBusyCursor();
}