Flex Data Management Services Tutorial

As part of the Flex Test Drive Server, I wrote a new Flex Data Management Services tutorial. The tutorial takes you through the full FDMS application development life cycle: Java assembler, destination, and client application. Additional topics include:

Click here to open the tutorial PDF document.

Your feedback on the tutorial and on the Flex Data Management Services in general is appreciated.

Thanks!
Christophe

Note: Refer to this post to download fds-tomcat.zip

ERRATA: On page 4: “On the Java Settings page, specify fdms-tomcat/classes as the Default output folder, and click Finish”. The name of the folder is incorrect: it should read: Specify “fds-tomcat/classes” as the Default output folder (The screen shot is correct).

Comments

46 Responses to “Flex Data Management Services Tutorial”

  1. Got RIA? » Blog Archive » FDS Examples With Tomcat By Christophe Coenraets on January 12th, 2007 1:06 pm

    [...] Collaboration Dashboard And in another post, he announced a Flex Data Management tutorial that’s also included in the Flex Test Drive Server. Good stuff if you’re looking to get into FDS. Kudos to one of Adobe’s Flex Evangelists! [...]

  2. Sree on January 13th, 2007 4:18 pm

    Christoph,

    There’s some confusion regarding the pdf doc.

    On page 4, you mention, specify fdms-tomcat/classes while in the screenshot, it says fds-tomcat/classes. Again, the folder does not exist. This is confusing and may be wrong. Please advise.

  3. christophe on January 13th, 2007 7:08 pm

    Hi,
    Good catch. The screen shot is right: it is fds-tomcat/classes. fds-tomcat refers to the name of the project. So “fds-tomcat\classes” actually points to C:\fds-tomcat\webapps\ROOT\WEB-INF\classes (assuming you unzipped in c:\).
    Thanks,
    Christophe

  4. amjad on January 20th, 2007 11:10 am

    Hi, I would like to get the tutorial to work with MYSQL. I was able to create and pouuplate the database.

    Could you please outline the changes required to config files etc so that I could start tomcat in eclipse and run the pages in the browse

  5. christophe on January 22nd, 2007 11:45 am

    Amjad,
    To get the tutorial to work with MySQL, all you need to do is change the JDBC connection parameters in WEB-INF\src\flexdemodb.properties (and make sure this file get copied to WEB-INF\src\flexdemodb.properties). The MySQL parameters should look like this:
    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql:///your_db_name
    Also, in the create() method of flex.tutorial.fdms.ProductDAO, comment out the following line of code
    ResultSet rs = s.executeQuery(”CALL IDENTITY()”);
    and uncomment
    ResultSet rs = s.executeQuery(”SELECT LAST_INSERT_ID()”);
    This is the MySQL syntax to get the value of the autogenerated key.

  6. Grace Tweedie on January 24th, 2007 8:30 am

    I am looking at your site based on Kevin Hoyt’s (from adobe) suggestion in his online seminar that I did yesterday. I am looking at all of this and it all seems a bit over my head. I am really wanting to get into Flex, however, I am looking for a simple gradient to start at. I know some very basic stuff in it already just from some of the help options and so forth. However, I would like to just roll on learning more about it, I wondered if you know of a simple place to start or what I should learn to begin with, etc. I am factually a graphic designer (Photoshop & InDesign), but I have got to get into Flex in order to pull off anything good in a whole project I am doing (creating a whole system with some nice GUI connected to databases, etc). I have my own programmer who is really getting into Java at the moment, but I have to roll too. I just have to roll in the right direction and learn as much as I can with the minimum of lost time. Can you give me some direction. Thank you in advance. Please don’t post this comment as it is more of a request for help.

  7. Sam on January 28th, 2007 2:24 pm

    We are in immediate need of a capable Flex Developer to develop an e-commerce experience.

    Contact me @: sam@pyromediastudios.com

  8. Steve on January 30th, 2007 9:22 am

    Christophe,

    I’m currently researching FDS and JAVA for an upcoming project. I’m not a JAVA developer - but it’s something I am working on at the moment. Anyway - do you suggest any design patterns or ways of breaking up larger applications - FDS side? For example an App which has 8 main tabs with multiple sub-tabs each with datagrids / forms?

    Any suggestions for further reading would great,

    Thanks

  9. rakri on January 30th, 2007 4:51 pm

    Hi Christophe ,
    I’ve seen all of your flex tutorial .
    thanks ! all are good.
    Now , i’m waiting for a sample with flex and hibernate where is two tables for example in the database.
    rakri

  10. Wajid Ali on January 30th, 2007 11:23 pm

    thanks Christophe, surely this tutorial is going to help me in my project.

    Everything is fine & running, just one thing, in Eclipse(having Flex perspective) the inventory.mxml cannot be shown in design mode, it prompts with an error “An unknown item is declared as the root of your MXML document. Switch to source mode to corret it”
    I found out that its pointing to flex-config.xml file & says “” As unknown configuration variable

    Any Idea?

  11. Martin on February 5th, 2007 11:48 am

    A reply to Wajid Ali:

    I got the same error with almost all my mxml files when I restart Felx Builder, a Google search revealed that a few others have the same problem too (and it lead me tp your entry in this blog)

    It seems to be a bug and the solution is quite simple:

    Go to your mx:Application tag and insert a line break after the namespace declaration, like so:

    [...]xmlns:mx=”http://www.adobe.com/2006/mxml” [line break]
    layout:absolute[...]

    After doing so the error will miraculously disappear, now you can even remove the line break.

    But the error will return when you restart Flexbuilder, unless you have that line break after the xmlns-declaration.

    HTH, Martin

  12. Curt on February 5th, 2007 6:47 pm

    Any tips on a free Flex IDE?

    tnx curt

  13. VJ on February 6th, 2007 7:27 pm

    Hi Christophe,

    I am a Flex newbie. I am following the tutorial from your pdf document. I get the following error in flex-config.xml

    “unknown configuration varialbe’compiler.keep-as3-metadata’”

    I have no clue how to fix this error. I would really appreciate if you could help.

    Thanks.
    VJ

  14. Sebastien on February 13th, 2007 3:11 am

    Great examples!!

    I made a tiny application that has to make some calculation. So I have to transform remote data in variables. I couldn’t do it with HTTPService or WebService as with those objects I can only do data binding.

    So I made an “XMLLoad” class with an EventDispatcher to parse the xml in a variable.
    Is there another way to do that?

    And how to do this with a WebService?

    Thanks.
    Seb

  15. Gene on February 16th, 2007 1:23 pm

    FYI… When running the tutorial, there is a bug that I was able to recreate. If you click on a field in a row to edit (say category), but then immediately click on that row’s ID field, followed by clicking the delete button, the row WILL be deleted in any other client connected and on the server. However, the row will not be deleted from the client that actually performed the delete. I was able to recreate this in both IE7 and Firefox 2 on XP. Not a big deal, but just thought I’d mention it.

    -Gene

  16. Tolga Erdogus on February 17th, 2007 8:23 am

    This is all nice and very exciting but I need an additional tutorial on how to “secure” hibernate queries. What should one use for an authentication layer/technology, what kind of code needs to be written in flex to login and authenticate (using what kind of server side technology?) and finally how and where to build a list of priviliges to authorize certain users to run certain queries and not allow other to…

  17. Oscar on February 20th, 2007 3:02 pm

    This is great material. There has been an increasing interest in the Spanish speaker Flex community for material such as this. Would you mind if I translate this material to Spanish and make available in the Flex Spanish speaking forums?

  18. Ajay on March 25th, 2007 10:16 pm

    Good Tutorial …
    Hi can u post a tutorial on flex hibernate java

  19. shridhar on March 28th, 2007 3:38 am

    I want to create new flex and hibernate application and do i need to change the properties file and create the class

  20. Mark on April 18th, 2007 1:46 am

    Thank You

  21. Andrew on April 25th, 2007 5:47 pm

    Works great, perfectly actually. The problem is that this Tomcat server has been modified in such a way that the projects developed here can’t be migrated. Can you provide a list of all the modifications to the “standard” FDS configuration files that you put in this project? I’ve been trying to track them all down but it seems the messaging service is still throwing errors when I deploy on a full version of Tomcat. Thanks!

  22. Salvo on May 7th, 2007 11:52 pm

    Hi all,
    Christoph thanks a lot for you job is really great.
    I found a problem using the tutorial, when I created the flex project(inventory.mxml).
    Eclipse give me back the following error
    “unknown configuration variable compiler.keep-as3-metadata”.
    I tried to use the suggestion coming from
    “Martin on February 5th, 2007″ but nothing changed.
    Can somebody help me ?
    thanks in advaced
    Salvo

  23. RIA pedia - Rich Internet Applications - Its all about the user experience! on June 15th, 2007 8:38 am

    Great Flex Samples with Christophe’s Salesbuilder Application…

    Christophe Coenraets has updated his Salesbuilder application with a number of unique features that would appeal to any Flex developer. (The application is an Adobe AIR application that he’s built with Flex Builder.) Salesbuilder is sample sales for…

  24. Brandon on June 18th, 2007 7:29 pm

    Hi, was doing a search on the error “An unknown item is declared as the root of your MXML document.” and came across your site. Great read btw. Anyway, didn’t find the answer here or anywhere else for that matter so I just went to messing around and found a fix/work a round or whatever you wanna call it.

    Im using Flex CS3 Beta to build my app and have it set up for AIR. In the top of my app file it had and the error was gone and hasn’t been back since. When you’re done working on it, you can change it back to the mx:WindowedApplication and all should be fine.

    Just thought I would share that.

  25. Ezmo Developer Blog » Using Flex Data Services with Spring and Hibernate on July 18th, 2007 4:16 am

    [...] I’m not going to write a lot about FDS here, so the curious reader may want to take a look at this article for an introduction to the subject. [...]

  26. andy on July 26th, 2007 4:27 pm

    Hi ,

    I was trying to connect to oracle database using FDMS but when I run the mxml file in browser and when I click on Getdata button which does the same thing “ds.fill(products)” but it does not retrieve the result from Database and it shows nothing on the command prompt of server. What can be the possible error? when there was error in the query it was giving error on server command prompt as “Numeric Overflow” but when the query was fine it showed nothing on command prompt just the message “server startup in 9340 ms”

  27. mub on July 27th, 2007 9:42 am

    Hi,

    I followed all the steps of your tutorial but when I am running inventory.mxml in browser I am getting this error:-

    [FaultEvent fault=[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error undefined url:'rtmp://localhost:2038'"] messageId=”62C35CB9-9D9F-D25D-C1E9-088946B1DB92″ type=”fault” bubbles=false cancelable=true eventPhase=2]

    Could you please help? no other application is using 2038 port. I also disabled my pc firwall as-well but still I am getting the same error.

    Any comments would be appreciated.

  28. gmcgoldrick on August 8th, 2007 3:24 am

    The Channel.Connect.Failed error is a red herring.

    The problem is that you need to “build” the server-side project. If you look at the tomcat log, it will show that it cannot find the ProductAssembler class.

    Maybe the tutorial could be updated to add in this important step.

  29. max on August 10th, 2007 5:49 am

    Christophe, thank u so much for interesting and useful bundle. This clear alot for me. But im looking for some implementations and really can’t find any to meet my needs. Could anyone post links or any related materials on topic. I need some solution to secure destinations as well as say different application modules based on roles.

    thanks in advance )

  30. cheewai on September 14th, 2007 1:45 am

    ([RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error undefined url:'rtmp://localhost:2037'"]
    )

    I getting this error when I try to use the data management, this is my configuration. I using EJB as persistent layer.

    ejb3
    FOModelBean/remote
    application

    20

    Please advice.

  31. Pepe Martínez on September 30th, 2007 10:08 am

    I haven’t found a solution for the problem of the error “unknown configuration variable ‘compiler.keep-as3-metadata’” found at flex-config.xml.

    I would appreciate any advice.

    Regards.

  32. ttnspy on November 1st, 2007 12:59 am

    I’m a have small problem , can any one help me? Please
    I make a project which very similar to Product project(in example).

    1) Have Assembler class: I work correctly

    package flex.samples.stock;

    import java.util.List;
    import java.util.Collection;
    import java.util.Map;

    import flex.data.DataSyncException;
    import flex.data.assemblers.AbstractAssembler;

    public class StockAssembler extends AbstractAssembler {

    public Collection fill(List fillArgs) {
    StockService service = new StockService();
    System.out.print(fillArgs.size());
    return service.getStocks();
    }

    public Object getItem(Map identity) {
    StockService service = new StockService();
    return service.getStock(((Integer) identity.get(”StockId”)).intValue());
    }

    public void createItem(Object item) {
    StockService service = new StockService();
    service.create((Stock) item);
    }

    public void updateItem(Object newVersion, Object prevVersion, List changes) {
    StockService service = new StockService();
    boolean success = service.update((Stock) newVersion);
    if (!success) {
    int stockId = ((Stock) newVersion).getStockId();
    throw new DataSyncException(service.getStock(stockId), changes);
    }
    }

    public void deleteItem(Object item) {
    StockService service = new StockService();
    boolean success = service.delete((Stock) item);
    if (!success) {
    int stockId = ((Stock) item).getStockId();
    throw new DataSyncException(service.getStock(stockId), null);
    }
    }

    }

    some require class is ok.
    2) I configure in data-management-config.xml

    flex.samples.stock.StockAssembler
    application

    20

    3) My client app:
    I use :
    ….

    ……
    ds.fill(stocks); –> Problem here
    When I run this app, The method fill() of StockAssembler on the server work correctly (i use printout to debug) . But variable stocks can’t get the return value,it is a empty list.

    Please help me!

  33. ttnspy on November 1st, 2007 1:01 am

    Hi all!
    I’m a have small problem , can any one help me? Please
    I make a project which very similar to Product project(in example).

    1) Have Assembler class: I work correctly
    package flex.samples.stock;

    import java.util.List;
    import java.util.Collection;
    import java.util.Map;

    import flex.data.DataSyncException;
    import flex.data.assemblers.AbstractAssembler;

    public class StockAssembler extends AbstractAssembler {

    public Collection fill(List fillArgs) {
    StockService service = new StockService();
    System.out.print(fillArgs.size());
    return service.getStocks();
    }

    public Object getItem(Map identity) {
    StockService service = new StockService();
    return service.getStock(((Integer) identity.get(”StockId”)).intValue());
    }

    public void createItem(Object item) {
    StockService service = new StockService();
    service.create((Stock) item);
    }

    public void updateItem(Object newVersion, Object prevVersion, List changes) {
    StockService service = new StockService();
    boolean success = service.update((Stock) newVersion);
    if (!success) {
    int stockId = ((Stock) newVersion).getStockId();
    throw new DataSyncException(service.getStock(stockId), changes);
    }
    }

    public void deleteItem(Object item) {
    StockService service = new StockService();
    boolean success = service.delete((Stock) item);
    if (!success) {
    int stockId = ((Stock) item).getStockId();
    throw new DataSyncException(service.getStock(stockId), null);
    }
    }

    }

    some require class is ok.
    2) I configure in data-management-config.xml

    flex.samples.stock.StockAssembler
    application

    20

    3) My client app:
    I use :
    ….

    ……
    ds.fill(stocks); –> Problem here
    When I run this app, The StockAssembler on the server work correctly (i use printout to debug) . But variable stocks can’t get the return value,it is a empty list.

    Please help me

  34. Building a LiveCycle Data Service Application « i am josh on November 8th, 2007 12:41 pm
  35. music on January 6th, 2008 4:08 pm

    very interesting.
    i’m adding in RSS Reader

  36. secretboy on February 12th, 2008 11:08 am

    great post.thanx

  37. pushkar on April 13th, 2008 9:32 am

    Hi Cristophe,

    I was going through the examples of yous, but none of the channels (be it my-rtmp/amf) are working for some peculiar reason. Is it that we need to install something for getting them work ? Please let me know
    as I am stuck with this for quite some time.

    Thanks.

  38. Maternity clothes. on June 25th, 2008 11:05 am

    Rockabilly clothes….

    Cool clothes. Sissy boys wearing girls clothes. Hippie clothes. 18 doll clothes. Small dog clothes. Girls clothes. Express clothes….

  39. sohbet on July 21st, 2008 4:11 am

    very interesting

  40. gaurav on August 13th, 2008 3:00 pm

    In your example in the pdf you are not using ds.createItem anywhere…!! can you please tell a way to use createItem from the client side.

  41. chat on August 22nd, 2008 6:54 am

    Good Tutorial …
    Hi can u post a tutorial on flex hibernate java

  42. sohbet on August 22nd, 2008 6:54 am

    very interesting.

  43. çet on August 22nd, 2008 6:55 am

    interesting ;)

  44. muhabbet on August 28th, 2008 5:44 am

    Thank you very much for this information. I like this site

  45. kızlarla sohbet on August 28th, 2008 5:45 am

    thank you very much.

  46. radyo dinle on August 28th, 2008 5:45 am

    ooo süper this is. fantastik

Leave a Reply