You can use the DAM data refresh mechanism to subscribe your component to receive updated data from the vSphere environment.
You can bind the requested data directly to elements in the view class, causing those elements to be updated whenever the requested data changes. To perform this binding, you must include a data update specification when you dispatch your data request event.
A data update specification is included in the SDK base class DataRequestInfo. You must create an instance of DataRequestInfo and set the DataUpdateSpec property, and then pass the DataRequestInfo object when you create your data request.
The DAM data refresh mechanism has different modes of operation. You specify the mode of operation with your choice of constructor for the DataUpdateSpec object that you pass to your DataRequestInfo object.
To create an implicit binding, you use the newImplicitInstance() method to construct the DataUpdateSpec object. To create an explicit binding, you use the newExplicitInstance() method.
The following example mediator class includes the DataRequestInfo and DataUpdateSpec objects to create an automatic binding in the data request. In the example, the DataUpdateSpec is constructed using the newImplicitInstance() method, resulting in an implicit binding.
In the example, the function onStart dispatches the initial DataByModelRequest. The initial request includes a DataRequestInfo object with an implicit DataUpdateSpec. The function onDataRetrieved is annotated to handle the response, and updates a UI control with the returned data. Because of the data update specification, the DAM calls onDataRetrieved when the data changes.
import com.vmware.data.query.events.DataByModelRequest; import com.vmware.data.query.DataUpdateSpec; import com.vmware.data.query.events.DataRequestInfo; [Event(name="{com.vmware.data.query.events.DataByModelRequest.REQUEST_ID}", type="com.vmware.data.query.events.DataByModelRequest")] public class MyVmViewMediator extends EventDispatcher { private function onStart():void { var requestInfo:DataRequestInfo = new DataRequestinfo(DataUpdateSpec.newImplicitInstance()); // create a DataRequestInfo with an implicit-mode DataUpdateSpec var myRequest:DataByModelRequest = DataByModelRequest.newInstance(vmRef, MyVmData, // data model requestInfo); // include the DataRequestInfo object when constructing the request dispatchEvent(myRequest); } [ResponseHandler(name="{com.vmware.data.query.events.DataByModelRequest.RESPONSE_ID}")] public function onDataRetrieved(request:DataByModelRequest, result:MyVmData):void { _view.vmData = result; } }