1 November 2010
Some experience with developing Flex applications will be helpful for this tutorial.
Beginning
One of the new data-centric development features in Flash Builder 4 is form generation, and it's going to make life easier for Flex developers. Now, you can automatically generate form code for data types or service calls and bind the controls to the properties of the required data type—all with just a few clicks of your mouse.
In this tutorial I will show three different ways in which you can generate a form using a sample service.
In Flash Builder, you can generate forms for the following:
The examples in this tutorial use a service called Population, which is available here.
Follow these steps to connect to the web service in Flash Builder 4:
The service is now visible in the Data/Services view (see Figure 6).
For a more detailed explanation of the setup steps, see my blog post on Connecting to WebServices using the Data Centric Development (DCD) feature in Flash Builder 4.
As a first example, you can generate a form to enter the details of an object of type Population_type. Follow these steps:
You can then edit the click handler of the Submit button to give the form a specific function.
Next, you'll see how to generate a form to display the returned data from the service call getWorldPopulation() .
getWorldPopulation() service call and select Generate Form (see Figure 11).
getWorldPopulation() operation of PopulationService (see Figure 12).getWorldPopulation() operation, select Form For Return Type, deselect Make Result Form Editable, and then click Configure Return Type.
getWorldPopulation() operation (see Figure 16).
Next, you'll see how to create a master detail view. In this example a ComboBox service as the master control and displays instances of the data type. The form shows the details of the selected item in the master control.
Follow these steps to see how it works:
This ComboBox is your master control, which will display a list of countries.
getCountries() operation (see Figure 18).
You have successfully bound the master control to its data.
In this example, the Population service has an operation named getPopulation(String), which takes the name of the country as an argument, and returns the details of that country.
getPopulation() operation are selected (see Figure 21).
Flash Builder will switch to Source view and highlight the change handler for the ComboBox. You'll see the following code:
protected function comboBox_changeHandler(event:IndexChangeEvent):void
{
getPopulationResult.token = population.getPopulation(/*Enter value(s) for */ strCountry);
}
getPopulation(String) operation to comboBox.selectedItem.toString().The code should look like this:
protected function comboBox_changeHandler(event:IndexChangeEvent):void
{
getPopulationResult.token = population.getPopulation(comboBox.selectedItem.toString());
}
When you change the selected country in the ComboBox, a service call is made and the population details of that particular country are fetched and displayed.
You have just seen how easy it is to create a form for a data type, for a service call, and for a master detail view using the data-centric development features in Flash Builder. To learn more about Flash Builder 4 and data-centric development, see Data-centric development with Flash Builder 4.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License