Building database-driven Flex applications without writing (Client- or server-side) code

One question that developers often ask when they see Flex for the first time is: “how do I write a database application?”

The answer to this question is typically: You use an HTTPService, WebService, or RemoteObject to connect to a server-side component that provides an API to manipulate your data. This approach provides infinite possibilities, but it makes the assumption that you already have that entire backend infrastructure in place. If you don’t, and all you want to do is build a rapid prototype or a simple application, this might look like a lot of work.

In addition to the RPC services mentioned above, the Flex Data Management Services (FDMS) provide a virtually code-free approach to synchronize data between the client application and the middle-tier. That takes care of 50% of our challenge: no data synchronization code to write at the client-side.

FDMS also provides a pluggable adapter and assembler architecture to handle changes at the server-side. As an example of writing a generic assembler, I built a simple JDBC assembler that allows you to develop rapid prototypes and basic database-driven applications without writing a single line of server-side code. All you need to do is specify the database connection information and the table you want to work with in data-management-config.xml.

This assembler is by no means a full featured solution, but it shows the power and flexibility of the FDMS architecture: you could easily extend its capabilities, or build other generic assemblers for existing persistence solutions (a Hibernate assembler is already shipping with the product).

The point is that if FDMS provides a solid architecture to handle the most complex persistence scenarios (with virtually no data synchronization code at the client side), with the addition of specialized assemblers, it can also provide simple solutions to simple use cases, significantly improve your productivity, and deliver end-to-end code-free persistence.

Installing the SimpleJDBCAssembler:

  1. To use the SimpleJDBCAssembler, you need to install the Flex Data Services. If you haven’t already done so, you can download the Flex Data Services here, and follow the installation instructions.
  2. Download jdbcassembler.zip here and expand it in your root directory (the files will be unzipped in a directory called jdbcassembler)
  3. Copy SimpleJDBCAssembler.class in {context-root}\WEB-INF\classes\flex\samples\assemblers. For example, if you installed the integrated server, copy SimpleJDBCAssembler.class in \fds\jrun4\servers\default\samples\WEB-INF\classes\flex\samples\assemblers.

Running the sample application:

  1. Copy the \jdbcdemo directory in the context root of your web application. For example, if you installed the integrated server, copy the \jdbcdemo directory in \fds\jrun4\servers\default\samples.
  2. Open {context-root}\WEB-INF\flex\data-management-config.xml and add the following destination:
  3. 
    
    
        
    
            flex.samples.assemblers.SimpleJDBCAssembler
            application
    
            
                
            
    
            
                org.hsqldb.jdbcDriver
                jdbc:hsqldb:/jdbcassembler/db/flexdemo
    product
    true
  4. This example uses an embedded HSQLDB database. Make sure hsqldb.jar is available in the classpath of your web application. For example in {context-root}\WEB-INF\lib. If you are using another database, make sure the JDBC driver for that database is in the classpath of your web application.
  5. Start the server
  6. Access http://localhost:8700/samples/jdbcdemo/simpleclient.mxml. (Change the port number and the context root as appropriate). This is a basic client built with just a few lines of code. You can edit the data inside the datagrid.
  7. Access http://localhost:8700/samples/jdbcdemo/app.mxml. (Change the port number and the context root as appropriate). This is a slightly more sophisticated client. You edit data in a separate form.

Also notice that changes are pushed in real time to all the clients connected to a destination. For example, open the application in two browser sessions, change some data in one session, and notice that the changes are automatically pushed to the second session.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • StumbleUpon
  • Twitter
This entry was posted in Flex. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

69 Comments

  1. Srini
    Posted July 22, 2008 at 12:30 am | Permalink

    hi we are planned to take seminar About the FLEx topic can you give the procedure to do the application(Sample Project) in Flex 3.0

  2. Posted August 22, 2008 at 6:07 pm | Permalink

    Thanks ….

  3. Posted August 22, 2008 at 6:08 pm | Permalink

    ThankS a lot ;)

  4. Posted August 22, 2008 at 6:10 pm | Permalink

    ThankS good ;)

  5. Posted November 9, 2008 at 6:01 pm | Permalink

    I’d highly recommend taking a look at the X2O Framework (www.x2oframework.com).

    It’s a web-based data modeling platform that generates the server-side infrastructure (database, server-side, web services) as well as generated AS3 value objects. You don’t have to do any rpc or remoting integration. Instead, it lets you focus on Flex programming and have all your data management there.

  6. Posted November 11, 2008 at 7:55 pm | Permalink

    I’d highly recommend taking a look at the X2O Framework (www.x2oframework.com).

    It’s a web-based data modeling platform that generates the server-side infrastructure (database, server-side, web services) as well as generated AS3 value objects. You don’t have to do any rpc or remoting integration. Instead, it lets you focus on Flex programming and have all your data management there.

  7. arathy
    Posted November 12, 2008 at 10:56 pm | Permalink

    hi
    Plz send me sample examples of database connectivity with oracle/db2 using flex>also send me the steps for connectivity and the required components like data service asap so that it will help me a lot
    my email
    arathy@mediainteractive.in

  8. arathy
    Posted November 12, 2008 at 10:57 pm | Permalink

    hi
    Plz send me sample examples of database connectivity with db2 using flex>also send me the steps for connectivity and the required components like data service asap so that it will help me a lot
    my email
    arathy@mediainteractive.in

  9. Posted November 20, 2008 at 9:17 pm | Permalink

    hi
    Plz send me sample examples of database connectivity with oracle/db2 using flex>also send me the steps for connectivity and the required components like data service asap so that it will help me a lot

  10. Posted November 26, 2008 at 9:05 am | Permalink

    Why do you have to be like MAcGyver to get flex to do anything. You know Adobe better get this data connection thing user friendly or Silverlight will surpass them for these type of projects. I should be able to go to the “Choose Data Source” feature in Flex, choose my server and database then flex needs to create the needed classes to make this work. I shouldnt need to got to useless blog after another to onlt hit more dead ends.

  11. Posted January 7, 2009 at 1:31 pm | Permalink

    How to connect to MS-SQL database and to retrive data ie a row and display it in the flex application please provide the code for the java dao and the flex part.

  12. James
    Posted February 13, 2009 at 3:34 pm | Permalink

    Is this database access solution working with Air?

  13. Posted July 13, 2009 at 7:12 am | Permalink

    How to connect to MS-SQL database and to retrive data ie a row and display it in the flex application please provide the code for the java dao and the flex part.

  14. Vimal
    Posted November 9, 2009 at 5:15 am | Permalink

    hi
    Plz send me sample examples of database connectivity with MYSQL using java flex builder 3 also send me the steps for connectivity and the required components like data service asap so that it will help me a lot

  15. Vimal
    Posted November 9, 2009 at 5:17 am | Permalink

    hi
    Plz send me sample examples of database connectivity with MYSQL using java flex builder 3 also send me the steps for connectivity and the required components. hear attach my mail id : vimal071982@gmail.com

  16. Posted November 24, 2009 at 6:28 am | Permalink

    how are you melisa

  17. Posted January 13, 2010 at 10:39 pm | Permalink

    good demo admin..

  18. Posted January 19, 2010 at 7:12 pm | Permalink

    mirc sohbet

    thank you For admin…!

  19. Posted February 2, 2010 at 9:18 pm | Permalink

    Thank for this nice informative article.

12 Trackbacks

  1. By Flex with java « Panduramesh’s Weblog on September 19, 2008 at 7:21 am

    [...] Questions About Enterprise Development Bruce Eckel :: Hybridizing Java Christophe Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code :: Introduces a SimpleJDBCAssembler FDMS adapter Christophe Coenraets :: Flex Test Drive Server for [...]

  2. By Flex with Java « anil4it on September 30, 2008 at 7:16 am

    [...] Questions About Enterprise Development Bruce Eckel :: Hybridizing Java Christophe Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code :: Introduces a SimpleJDBCAssembler FDMS adapter Christophe Coenraets :: Flex Test Drive Server for [...]

  3. By It’s all about RIA on October 13, 2008 at 11:35 pm

    [...] Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code :: Introduces a SimpleJDBCAssembler FDMS [...]

  4. By Java fx « Flex Generation Weblog on October 14, 2008 at 2:03 am

    [...] Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code :: Introduces a SimpleJDBCAssembler FDMS [...]

  5. By Adobe Flex With Java « welcome nandhu on October 22, 2008 at 10:51 pm

    [...] Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code :: Introduces a SimpleJDBCAssembler FDMS [...]

  6. By Flex with java « Adiflex’s Blog on October 25, 2008 at 6:12 am

    [...] Questions About Enterprise Development Bruce Eckel :: Hybridizing Java Christophe Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code :: Introduces a SimpleJDBCAssembler FDMS adapter Christophe Coenraets :: Flex Test Drive Server for [...]

  7. By Adobe LCDS « SrikanthCreative Mind’s Weblog on October 27, 2008 at 6:59 am

    [...] Christophe Coenraets :: Building database-driven Flex applications without writing (Client- or server-side) code [...]

  8. By Bookmark: 60+ Adobe Flex reference websites on January 11, 2009 at 12:33 pm

    [...] Application -  riapedia.com Need a ColdFusion Based FLEX Application Example – mail-archive.com Building database-driven Flex applications without writing (Client- or server-side) code – coenraets.org FLEX Applications Showcase Gallery – flexexamples.blogspot.com Help with simple [...]

  9. [...] Building database-driven Flex applications without writing (Client- or server-side) code – coenraets.org [...]

  10. [...] Building database-driven Flex applications without writing (Client- or server-side) code – coenraets.org [...]

  11. [...] Building database-driven Flex applications without writing (Client- or server-side) code – coenraets.org [...]

  12. By 16 » January » 2010 » 博兮博客 on January 16, 2010 at 12:39 am

    [...] Building database-driven Flex applications without writing (Client- or server-side) code – coenraets.org [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>