Flex Data Management Services Tutorial

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:

  • Controlling when changes are sent to the server
  • Controlling client synchronization (autoSyncEnabled)
  • Single Item vs Batch Updates
  • Conflict resolution
  • Locking strategies
  • Fill queries
  • Single Objects vs Collections

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).

  • 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.

122 Comments

  1. Posted January 13, 2007 at 4:18 pm | Permalink

    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.

  2. christophe
    Posted January 13, 2007 at 7:08 pm | Permalink

    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

  3. amjad
    Posted January 20, 2007 at 11:10 am | Permalink

    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

  4. christophe
    Posted January 22, 2007 at 11:45 am | Permalink

    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.

  5. Grace Tweedie
    Posted January 24, 2007 at 8:30 am | Permalink

    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.

  6. Posted January 28, 2007 at 2:24 pm | Permalink

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

    Contact me @: sam@pyromediastudios.com

  7. Steve
    Posted January 30, 2007 at 9:22 am | Permalink

    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

  8. rakri
    Posted January 30, 2007 at 4:51 pm | Permalink

    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

  9. Wajid Ali
    Posted January 30, 2007 at 11:23 pm | Permalink

    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?

  10. Martin
    Posted February 5, 2007 at 11:48 am | Permalink

    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

  11. Curt
    Posted February 5, 2007 at 6:47 pm | Permalink

    Any tips on a free Flex IDE?

    tnx curt

  12. VJ
    Posted February 6, 2007 at 7:27 pm | Permalink

    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

  13. Sebastien
    Posted February 13, 2007 at 3:11 am | Permalink

    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

  14. Gene
    Posted February 16, 2007 at 1:23 pm | Permalink

    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

  15. Tolga Erdogus
    Posted February 17, 2007 at 8:23 am | Permalink

    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…

  16. Oscar
    Posted February 20, 2007 at 3:02 pm | Permalink

    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?

  17. Posted March 25, 2007 at 10:16 pm | Permalink

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

  18. shridhar
    Posted March 28, 2007 at 3:38 am | Permalink

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

  19. Posted April 18, 2007 at 1:46 am | Permalink

    Thank You

  20. Andrew
    Posted April 25, 2007 at 5:47 pm | Permalink

    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!

  21. Salvo
    Posted May 7, 2007 at 11:52 pm | Permalink

    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

  22. Posted June 18, 2007 at 7:29 pm | Permalink

    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.

  23. andy
    Posted July 26, 2007 at 4:27 pm | Permalink

    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”

  24. mub
    Posted July 27, 2007 at 9:42 am | Permalink

    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.

  25. gmcgoldrick
    Posted August 8, 2007 at 3:24 am | Permalink

    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.

  26. max
    Posted August 10, 2007 at 5:49 am | Permalink

    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 )

  27. cheewai
    Posted September 14, 2007 at 1:45 am | Permalink

    ([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.

  28. Pepe Martínez
    Posted September 30, 2007 at 10:08 am | Permalink

    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.

  29. ttnspy
    Posted November 1, 2007 at 12:59 am | Permalink

    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!

  30. ttnspy
    Posted November 1, 2007 at 1:01 am | Permalink

    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

  31. Posted January 6, 2008 at 4:08 pm | Permalink

    very interesting.
    i’m adding in RSS Reader

  32. Posted February 12, 2008 at 11:08 am | Permalink

    great post.thanx

  33. pushkar
    Posted April 13, 2008 at 9:32 am | Permalink

    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.

  34. Posted July 21, 2008 at 4:11 am | Permalink

    very interesting

  35. gaurav
    Posted August 13, 2008 at 3:00 pm | Permalink

    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.

  36. Posted August 22, 2008 at 6:54 am | Permalink

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

  37. Posted August 22, 2008 at 6:54 am | Permalink

    very interesting.

  38. Posted August 22, 2008 at 6:55 am | Permalink

    interesting ;)

  39. Posted August 28, 2008 at 5:44 am | Permalink

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

  40. Posted August 28, 2008 at 5:45 am | Permalink

    thank you very much.

  41. Posted August 28, 2008 at 5:45 am | Permalink

    ooo süper this is. fantastik

  42. Posted September 1, 2008 at 4:28 am | Permalink

    thanks

  43. Posted September 14, 2008 at 2:32 pm | Permalink

    Thank you very much

  44. Posted October 8, 2008 at 7:00 am | Permalink

    Sohbet

    thanks you administrator

  45. Posted October 8, 2008 at 7:00 am | Permalink

    Güzel Sözler

    very much

  46. Posted October 10, 2008 at 11:14 pm | Permalink

    danke admin

  47. Posted October 10, 2008 at 11:16 pm | Permalink

    tek yuo admin

  48. Posted October 13, 2008 at 2:36 am | Permalink

    thanks for you

  49. Posted October 16, 2008 at 9:38 pm | Permalink

    This is one of the best FLEX examples on web.
    Thankyou very much for creating such a great examples.

  50. Madhu
    Posted November 2, 2008 at 11:55 am | Permalink

    Hi Chris

    Myself madhu i am new to flex ,i need your help in learning flex,and at the same time iam also looking for job on flex,i would be a very helpfull if can send me some FAQ’s . my mail id is madhu52280@gmail.com

    Thanks & Regards
    Madhu

7 Trackbacks

  1. [...] 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. 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…

  3. [...] 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. [...]

  4. By Maternity clothes. on June 25, 2008 at 11:05 am

    Rockabilly clothes….

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

  5. By About LCDS « It’s all about RIA on October 16, 2008 at 3:37 am

    [...] Christophe Coenraets :: Flex Data Management Services Tutorial [...]

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

    [...] Christophe Coenraets :: Flex Data Management Services Tutorial [...]

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>