Updated for Flash Builder 4 Beta 2 and LiveCycle Data Services 3 Beta 3
In this article we will see how we can do model-driven development using Flash Builder 4 and LiveCycle Data Services 3 beta. We will create a Flex application to perform CRUD operations on a database table without writing code.
Install LCDS 3
Download LiveCycle Data Services 3 from this URL http://labs.adobe.com/technologies/livecycle_dataservices3/. You will be downloading a file named livecycle_dataservices3_b3_win_100509.exe, execute this file to install. I have installed LCDS 3 with Tomcat to C:\lcds3
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_100509.zip, extract the contents of the zip file to a folder called livecycle_dataservices3_modelerplugin_100509. Copy the files under livecycle_dataservices3_modelerplugin_100509/plugins folder into C:\Program Files\Adobe\Adobe Flash Builder Beta 2\plugins.
Create sample database required
You can download the SQL file for the table used in this sample at this URL http://sujitreddyg.com/fb4articles/beta2/customers.sql.txt
Setting up data source
We need to expose databases as data sources. Fiber modeler plugin will use the data sources configured on the web server to get details of the tables in the database. In this sample, we will use lcds web application and the database created above. Add data source pointing to the database by modifying C:\lcds3\tomcat\conf\Catalina\localhost\lcds.xml as shown below. Make sure you have MySQL Connector/J in your tomcat lib folder.
<Context privileged=”true” antiResourceLocking=”false” antiJARLocking=”false” reloadable=”true”>
<Transaction factory=”org.objectweb.jotm.UserTransactionFactory” jotm.timeout=”60″/>
<Resource name=”jdbc/test” auth=”Container”
type=”javax.sql.DataSource”
username=”UserName”
password=”Password”
driverClassName=”com.mysql.jdbc.Driver”
url=”jdbc:mysql://localhost:3306/test?autoReconnect=true”/>
</Context>
Enabling RDSDispatchServlet
Flash Builder and Fiber Modeler plugin use the RDSDispatchServlet (part of LCDS) to retrieve information like data source, destinations, etc. by default the RDSDispatchServlet is commented out in web.xml. Open C:\lcds3\tomcat\webapps\lcds\WEB-INF\web.xml using a text editor and remove comment around RDSDispatchServlet Servlet definition and the URL mapping as shown below. Also set the useAppserverSecurity parameter value to “false” as shown below.
<servlet>
<servlet-name>RDSDispatchServlet</servlet-name>
<display-name>RDSDispatchServlet</display-name>
<servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>
<init-param>
<param-name>useAppserverSecurity</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping id=”RDS_DISPATCH_MAPPING”>
<servlet-name>RDSDispatchServlet</servlet-name>
<url-pattern>/CFIDE/main/ide.cfm</url-pattern>
</servlet-mapping>
Start LCDS server
Start LCDS server from the start menu, start -> All Programs -> Adobe -> LiveCycle Data Services ES 3.0 -> Start LiveCycle Data Services 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 2
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
- Set the SDK version to 3.4
- Set the Application server type to J2EE
- Select Use 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:\lcds3\tomcat\webapps\lcds
- Set the Root URL to http://localhost:8400/lcds
- Set the Context root to /lcds
- 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 using Fiber Modeler Plugin. For the modeler plugin to retrieve data sources we configured, we need to configure RDS Server settings in Flash Builder.
Configure RDS Server
Select preferences from 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 web application as shown in the image below.
In this screen:
- 1. Set the description to LCDS (localhost)
- Set the host name to 127.0.0.1
- Set the port number to 8400
- Set the Context root to lcds
- Leave the User name and Password blank under the Security Information section
- Click on Test Connection to check if everything is properly configured
- Click OK to continue
We configured RDS, let’s create a model.
Creating model using Fiber Modeler plugin
Right click on the MDDSample Flex project and create new Data Model file as shown in the image below. If you cannot view Data Model in the options, you can select other and find Data Model under the Data Modeling 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 Customer.fml and click on Next to continue.
In this screen, since we want to create model from a table in the database 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 available.
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 (localhost), one we created in previous steps
- Data sources available will be listed down. Select java:/comp/env/jdbc/test
- Tables available in the data source will be listed, select customers table
- Click on Finish to continue
Fiber Modeler Plugin will create Customer.fml based on the Customers table. Adobe Data Model perspective will launched as shown in the image below.
In this screen click Yes to launch Adobe Data Model perspective. You will see Customer entity represented graphically as shown in the image below.
Let’s deploy this model to the server. Right click on the Customer.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 (localhost)
- Set the model name to Customer
- Set the Database Tables to Unchanged
- Click on Finish to continue
Fiber Modeler Plugin deploys the Customer 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.
Now that we have our model deployed, we will consume the data in the Customers 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 RDS authentication 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 Customer.Customers is created whose associated source class is fiber.data.assemblers.FiberAssembler and the service type is data-service. Select the destination and click on Finish to continue.
Flash Builder will generate all code required to consume the service selected and will list the CustomersService in the services explorer as shown in the image below.
You can also see that the return types are properly set. Now that we have the service created, let’s 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 vertical
- Drag and drop a DataGrid on to the design view
- Set the editable property of the DataGrid to true
- Set the width of the DataGrid to 100%
Now let’s bind the data to DataGrid.
In this screen:
- Select the DataGrid
- Right click on the DataGrid
- Select Bind To Data
You will a window launched with options to select the service.
In this screen:
- Select New service call
- Set the Service to CustomersService
- Set the Operation to getAll(): Customers[]
- Click on OK to continue
You will see that the DataGrid will change its columns to reflect the properties of the Customer 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 so that 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. Also set the DataGrid editable to true.
customersService.serviceControl.autoCommit = true;
Save and run the application. You can edit the data in the DataGrid and just press enter key, 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/
We created a complete Flex application using Flash Builder 4 and LiveCycle Data Services 3 to perform operations on the data in the database in few minutes. Now that’s Rapid Application Development.
LCDS 3 Rocks

























June 24, 2009 at 12:10 pm
Thank you for sharing information about Flash Builder 4,I currently use that’s software and encountered some difficulties.
June 26, 2009 at 3:21 am
Instead of connecting to sample data base i wanted to connect to Mysql database server which is running in the port 3306 ?
can you tell me the step please ?
June 28, 2009 at 2:29 pm
Very helpful tutorial on an extremely cool technology. Thanks!
June 28, 2009 at 2:47 pm
How would server-side authentication and security be worked into the Fiber system?
July 1, 2009 at 5:18 pm
@Megharaja (post nr1)
You have to add within the context the following: ( of the webapp or in tomcat/conf/context.xml)
Then the db/tables appear in RDS Dataview of FB4
@Phil (post nr3)
If you find out how that works, please let me know.
@Sujit Reddy G
Thanks for all these informations, they are very helpfull.
Can you please post somtheing how to use security constraints with fiber.
I use to create a security-constraint in the services-config, and assigned that to the destination. But how can I do that if the destination is automaticly created from the FiberAssembler?
Cheers!
Martin Zach
July 1, 2009 at 5:22 pm
This part did’t come through, so again:
July 8, 2009 at 5:54 pm
Now am able to view the tables in the RDS treeview but when i drag and drop in the model file (fml) it supposed to generate service automatically. But it is generating the service. Please let me know if you have any solutions.
July 14, 2009 at 7:40 pm
I tried following your example, and man is this stuff hard to get going. I cannot for the live of me connect to the samples database, but i managed to get the RDS working and pointing to my SQL databse server. However when ever i try to add a table to it i get the following. “Unsupported db operation: DBDESCRIPTION”. what am i doing wrong?
July 20, 2009 at 8:52 pm
Hi Anton,
Can you please let us know what difficulties you are facing.
July 20, 2009 at 9:06 pm
Hi Megharaja,
Please check article at this URL http://confluence.atlassian.com/display/CONF256/Configuring+a+MySQL+Datasource+in+Apache+Tomcat
Hope this helps.
July 20, 2009 at 9:19 pm
Hi Megharaja,
Services are not generated when the FML file is created, they will be created when you deploy the FMl file on the server.
Hope this helps.
July 20, 2009 at 9:30 pm
Hi Rob,
Can you please try sending the FML file created? Thank you.
July 21, 2009 at 7:47 am
Hi All,
Thanks for your help. Now am able to generate all the services and able to pull all the data from the MYSQL database in my Adobe AIR app. I was trying to make my application works offline and automatic synchronization. The service which creates is wrapper for the data service. Can anyone help me how to achieve this?
July 22, 2009 at 5:10 am
I’ll be wait for the next post.
thanks.
October 30, 2009 at 4:41 pm
Hi
I followed the steps mentioned above to create MDDSample Application using Flash Builder 4 Beta 2 and LiveCycle Data Services 3 Beta 3.
When i tried deploying the datamodel to lcds, i am getting the following error “one error found while reading model Customer: XML parse error: Error on line 1 of the document cvcelt.1:Cannot find declaration of element model……”
Please help me in solving this issue.
Thanks
Rao