Commit an Object

Description

This section describes how to commit an object from your widget in JavaScript. Tutorials related to this subject can be found here.

Instructions

Create or retrieve the object.

Make sure you have your object in the scope for your function. You can get one by creating a new one or by retrieving it from either context or a mx.processor.getObject() call.

Set the object’s attributes.

To change an attribute of an object, you can use setAttribute().

orderObj.setAttribute("ProductName", "Margarita pizza");

Save the object.

Now we’ll send the changes to cache and the server using object.save(). This function saves the object in cache and results in an asynchronous call, sending the changes to the server. This function accepts 2 functions, a callback and an error function.

If your widget is in a Data view and you are editing the object of the Data view, it will be automatically committed when the form is saved. Use this for any changes to the actual Data view object, as the user might want to cancel their changes without committing the object.