Expand my Community achievements bar.

Mapping Objects in Flex Data Services

Avatar

Level 2

Hi My Dear Friends

This is yogans, i am working in flex for the last 15 days
and i learned the basic things like syntax, tags, scripts. and i am
doing

some data services work now. especially with the help of
Java Remote objects. I dont know http services and
webservices(WSDL).

My doubt here is, I created a user defined object in java
and i want to send this object through Remote call from flex. how
can i

type cast the java object to flex. And i want to add these
objects to the dataprovider of a datagrid. Please help me in
acheiving

this. i will be very thank ful to you in my life. I know
that i have to create same kind of object in flex. But i dont have
concrete idea



please explain me with very simple example step by step . I
am awaiting in hope that God will send some one to help me.



Thanks and Regards

Yogans.s
1 Reply

Avatar

Level 3
Hi,



If you want to map your actionscript class to your server's
Java class. You can run a util function

registerClassAlias("dev.echoservice.Book",Book);

where "dev.echoservice.Book" is the fully qualify name of
your java class. Book is your actionscript class.

Calling this util before you make your remoteobject call. You
can put this in your actionscript class constructor, it makes this
call whenever you create your class. However, it seems to be better
to call it when the class is loaded. To do so you can declare it as
static

public static var a:* =
registerClassAlias("dev.echoservice.Book",Book);



OR

You can also declare it as metaData in your class as:



[RemoteClass(alias="dev.echoservice.Book")]

However, I found someone saying that it didn't work in sdk
compilation, but webtier compilation. It might be some
configuration issue. I haven't tried it yet.

To display the properties in the dataGrid, you just have to
either use Array or ArrayCollection. If databinding is involved,
the datagrid need to know the Collection.Change event. It is better
to use ArrayCollection, therefore, adding new item to
arrayCollection the datagrid get repopulate.



hope it helps!



William Chan