Converting Date from ActionScript to Java

Avatar

Avatar

shaun000

Avatar

shaun000

shaun000

12-06-2008

Hi,

I have a Flex frontend and a Java backend. When I send an
object with a date field from flex to my backend it converts the
date field to a java.util.Date. The problem is that the class in
java has defined the date field as a Timestamp so when the object
is received as a parameter in the backend it throws an arguement
type mismatch. Is there anyway a flex date value can be sent and
recognised by Java as a Timestamp.

Replies

Avatar

Avatar

anirudhs

Avatar

anirudhs

anirudhs

18-06-2008

Hi,



Try calling registerClassAlias("java.util.Timestamp", Date)
on the flex side before sending AMF data.

Avatar

Avatar

shaun000

Avatar

shaun000

shaun000

03-07-2008

Finally got to try that out but I don't understand how this
is supposed to work. Do I just insert it anywhere ie a delegate
class



public function Delegate( responder : IResponder )

{

this.responder = responder;

this.service = ServiceLocator.getInstance().getRemoteObject(
"bla");

}



public function saveTime() : void

{

var token:AsyncToken;

registerClassAlias("java.util.Timestamp", Date);

var startTime:Date = new Date();

token = service.saveDate(startTime)

}

Avatar

Avatar

anirudhs

Avatar

anirudhs

anirudhs

03-07-2008

That should work. All you need to do is call it once before
the first call to the remote object. You can do it when the
creationComplete event of your application fires or just about
anywhere really.



Basically that call tells Flex that the remote type of the
Date class of Flex is java.util.Timestamp.

Avatar

Avatar

shaun000

Avatar

shaun000

shaun000

06-07-2008

Thanks for your help. Still didn't work but that's perhaps
because i'm using Weborb and I thought it would be the same.