0 Replies Latest reply on Nov 15, 2007 3:07 PM by (Laurie_Hall)

    ItemReference - shouldn't it contain the id generated by my Assembler's create function

    Level 1

      If anyone could help me with this I'd appreciate it. I've used the fds-tomcat.zip testdrive sample app to code this.

      Here's the facts:

      1) My custom service generates an id and inserts the record into my table successfully. From my Service.java:

      Statement s = c.createStatement();
      ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID()"); // unique userid

      // System.out.println("user.setUserid " + user.getUserid() + ".");

      The println displays the userid I want to use later on properly, but the client never seems to "see" it. The ItemReference in my client code does not display the same userid, it always displays 0. Debug mode shows all the values for the insert populated, but not the userid. It's set to zero. Here is my client code:

      import mx.data.ItemReference;
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;
      import mx.events.*;
      import mx.rpc.events.FaultEvent;
      import mx.utils.ArrayUtil;
      import classes.tfdao.User;

      private function handleRegister(event:Event):void {

      var dsuserDAO:DataService = new DataService ("UserDAO");
      var user:User = new User();
      user.firstname = this.firstname.text;
      user.lastname = this.lastname.text;
      user.lastmoddate = new Date();
      var userIR:ItemReference = dsuserDAO.createItem(user);

      var dsaddressDAO:DataService = new DataService("AddressDAO");
      var address:Address = new Address();
      // address.userid = ????????
      address.addressid = null;
      address.addresstypeid = 1;
      address.address1 = this.address1.text;
      address.address2 = this.address2.text;
      // yada yada ...
      var addressIR:ItemReference = dsaddressDAO.createItem(address);

      this.currentState = "registerSuccess";


      2) How do I reference the generated userid? I thought it should be in the Item Reference, but why is it always zero? Is there something I need to do in the data-management-config.xml to make it recognize what I'm trying to accomplish? I must have missed something -- but I am stumped!

      Laurie Hall