In this article we will see how we can do model-driven development using Flash Builder 4 and LiveCycle Data Services 3 beta. At the end of this article we will have a Flex application using which we can perform operations on the data in a database table. We will build this Flex application just using Adobe tools and not writing any Flex or Java code
Install LCDS 3
Download LiveCycle Data Services 3 beta from this URL http://labs.adobe.com/technologies/livecycle_dataservices3/. You will be downloading a file named livecycle_dataservices3_b1_win_061509.exe, execute this file to install. I have installed LCDS 3 with Tomcat to C:\lcds3beta
Set up Fiber modeler plugin
Download Fiber modeler plugin from this URL http://labs.adobe.com/technologies/livecycle_dataservices3/. You will be downloading file named livecycle_dataservices3_modelerplugin_061509.zip, extract the contents of the zip file to a folder called livecycle_dataservices3_modelerplugin_061509. Copy the files under livecycle_dataservices3_modelerplugin_061509/plugins folder into C:\Program Files\Adobe\Flash Builder Beta\plugins.
Setting up data source
We need to expose databases as data sources. Fiber modeler plugin will use the data sources to get details of the tables in the database. In this sample, we will use lcds-samples web application and the samples database which are bundled with LCDS 3. Data source for the LCDS sample data base is already set up for us in C:\lcds3beta\tomcat\conf\Catalina\localhost\lcds-samples.xml
Setting up RDSDispatchServlet
Flash Builder and Fiber Modeler plugin use the RDSDispatchServlet to get information like data source, destinations, etc. by default the RDSDispatchServlet is commented in web.xml. Open C:\lcds3beta\tomcat\webapps\lcds-samples\WEB-INF\web.xml using a text editor and remove comment around RDSDispatchServlet Servlet definition and the URL mapping.
Start LCDS and samples database
Start LCDS samples data base from the start menu, start -> All Programs -> Adobe -> LiveCycle Data Services ES2 Version 3 Beta -> Start samples database
Start LCDS server from the start menu, start -> All Programs -> Adobe -> LiveCycle Data Services ES2 Version 3 Beta -> Start LiveCycle Data Service Server
Please make sure both the database and the server are started.
We have everything ready to develop a Flex application using Flash Builder 4, Fiber modeler plugin and LCDS 3.
Create a Flex project
Start Flash Builder 4 from the start menu, start -> All Programs -> Adobe -> Adobe Flash Builder Beta
Create a Flex project from the file menu as shown in the image below.
You will see a window launched with options to fill project properties as shown in the image below. Fill project properties as shown in the image below.
In this screen:
- Set project name to MDDSample
- Let the Application type be Web
- Let the SDK version be default
- Set the Application server type to J2EE
- Select User remote object access service check box
- Select LiveCycle Data Services ES
- Click next to continue
Now we need to set the server properties, you will see a screen with options to set the server properties as shown in the image below.
In this screen:
- Set the Root folder to c:\lcds3beta\tomcat\webapps\lcds-samples
- Set the Root URL to http://localhost:8400/lcds-samples/
- Set the Context root to /lcds-samples
- Click on validate Configuration to validate server configuration
- Leave the Output folder to default, which is on the server
- Click finish to continue
Flash Builder will create a project with a default application file. Now let’s build the model from a database table using Fiber Modeler Plugin. For the modeler plugin to retrieve data sources we configured, we need to configure RDS Server.
Configure RDS Server
Select preferences from the window menu as shown in the image below.
In the preferences window, you will find RDS configuration panel under Adobe -> RDS Configuration as shown in the image below.
Configure RDS Server for lcds-samples web application as shown in the image below.
In this screen:
- Set the description to LCDS-SAMPLES (localhost)
- Set the host name to 127.0.0.1
- Set the port number to 8400
- Set the Context root to lcds-samples
- Leave the User name and Password blank under the Security Information section
- Click OK to continue
We configured RDS server, let’s create a model.
Creating model using Fiber Modeler plugin
Right click on the the MDDSample Flex project and create new Data Model file as shown in the image below.
Window with option to fill model properties will be launched as shown in the image below.
In this screen, set the File name to Product.fml and click on Next to continue.
In this screen, since we want to create model from a table in the database we will select From a database. Click Next to continue. Next screen will give you option to select the RDS server configured in previous steps and to view the data sources exposed.
In this step, we will select the database table from which the model has to be created.
In this screen:
- Set the RDS Server to LCDS-SAMPLES (localhost), one we created in previous steps
- Data sources available will be listed down. Select java:/comp/env/jdbc/ordersDB
- Tables available in the data source will be listed, select PUBLIC.PRODUCT
- Click on Finish to continue
Fiber Modeler Plugin will create Prouct.fml based on the Product table. You will see the Adobe Data Model perspective will launched as shown in the image below.
In this screen, you can click on Yes to launch Adobe Data Model perspective. You will Product entity represented graphically as shown in the image below.
Let’s deploy this model to the LCDS server. Right click on the Product.fml and select Deploy Data Model to LCDS Server as shown in the image above. Window with deployment options will be launched as shown in the image below.
In this screen:
- Set the RDS Server to LCDS-SAMPLES (localhost)
- Set the model name to Product
- Set the Database Tables to Unchanged
- Click on Finish to continue
Fiber Modeler Plugin deployed the Product model to the server. LCDS 3 will create required assembler and also create a data management destination. All we have to do now is to see how we can consume the service and create a Flex application. With Flash Builder 4 this is very simple, let’s see how Data centric Development (DCD) features in Flash Builder 4 lets us easily consume data management services and bind them to UI controls.
Consuming data management services from Flash Builder 4
Switch to Flash perspective and Select MDDSample.mxml. You can switch perspective from right hand side top corner. Select the Data/Services panel also called services explorer as shown in the image below.
We will consume the data in the Product table and bind the data to a UI control. Click on the Connect to Data/Service link as shown in the image above.
You will see a window launched with options to select the type of service as shown in the image below.
In this screen, select LCDS and click on Next to continue. You will be prompted for credentials, since we don’t have this enabled, just select No password required check box and click OK to continue.
Now Flash Builder will retrieve all the Remoting and Data Management destinations exposed by the web application and displays as shown in the image below.
You can see that a destination named Product.Product is created whose associated source class is fiber.data.assemblers.FiberAssembler and the service type is data-service.
In this screen:
- Set the Service name to ProductService
- Select Product.Product destination
- Set the package name to services.productservice
- Click on Finish to continue
Flash Builder will generate all code required to consume the service selected and will list the ProductService in the services explorer as shown in the image below. You can also see a window displayed with next logical steps. Read the next logical steps and click on OK.
You can also see that the return types for the service operations are properly set. Now that we have the service created, lets bind the data to a UI control. Switch to design view as shown in the image below.
In this screen:
- Set the layout of the Application to spark.layouts.VerticalLayout from the properties panel
- Drag and drop a DataGrid on to the design view
- Set the width of the DataGrid to 100%
Now let’s bind the service result to DataGrid.
In this screen:
- Select the DataGrid
- Right click on the DataGrid
- Select Bind To Data
You will see a window launched with options to select the service as shown in the image below.
In this screen:
- Select New service call
- Set the Service to ProductService
- Set the Operation to getAll
- Click on OK to continue
You will see that the DataGrid will change its columns to reflect the properties of the Product entity. Save the application and run the application. Application will launch in the browser. You can observe the application sending request to the server and displaying the response in the DataGrid as shown in the image below.
Let’s enable auto commit and so the changes to the data on the client will automatically be updated on the server and hence this will be a complete application. Switch to code view and this line of code to enable auto commit as shown in the image below.
productService.serviceControl.autoCommit = true;
Save and run the application. You can edit the data in the DataGrid and just press enter, the data will automatically be committed in the database. Refresh the application to confirm.
More articles on how to use Flash Builder 4 are available at this URL http://sujitreddyg.wordpress.com/flash-builder-4/
Few minutes back we had a database table, we created a complete Flex application to perform operations on the data in the database using Adobe tools. Now that’s Rapid Application Development.
There are lots of additions to the LiveCycle Data Services 3, try them.
LCDS 3 Rocks











































































































































