Hi, 

If anyone could help me with this I'd appreciate it!

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 
rs.next(); 
user.setUserid(rs.getInt(1)); 

System.out.println("user.setUserid " + user.getUserid() + "."); // 
this prints the new unique id correctly
... 

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 (below) does not display the same userid as server generated, it 
always displays 0. For example, debugger shows all the values for the 
insert populated in userIR obect, accept the userid.  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 = userIR.userid --> this won't work, but do I get 
the value in 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 the generated userid? I must have missed something -- but I am 
stumped! 

Thanks! 


Reply via email to