Retrieving data from a Flex data model

You can create bindings that retrieve data from data models. For example, you can create a binding that retrieves employee information from a data model so that you can display the information in your MXML file.

To create a binding that retrieves data from a data model:

  1. Make sure your MXML file contains a component, data model, or data service that can accept the data from the data model.

    For example, your file can have a Label component that will display an employee name received from the data model.

  2. In the Data panel, select the data model.
  3. In the Bindings panel (Window > Bindings), click the Plus (+) button.

    The Add Binding - Step 1 dialog box appears.

  4. Select the second option ("Data Will Flow From") and then select the property of the data model to supply the data.

    For example, if you want to retrieve an employee name from the data model, select the appropriate name property of the data model.



    The Binding Source text box displays the binding expression Flex Builder will insert in the code. If you want you can modify the expression. For more information, see "Binding data" in Developing Flex Applications Help.

  5. Click Next.

    The Add Binding - Step 2 dialog box appears.

  6. Select the destination of the data supplied by the data model.

    The destination can be the property of a component, a data service, or even another data model.

    For example, if you have a Label component that you want to use to display the employee name, select the Label component in the left pane and then select the text:String property in the right pane.



  7. Click Finish to create the binding.

    The new binding appears in the Bindings panel.

  8. If the destination of the data is a data service such as a web service, specify the event that invokes the data service.

    For instructions, see Calling the data service.