aspose file tools*
The moose likes Flex and the fly likes Passing Flex objects to Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "Passing Flex objects to Java" Watch "Passing Flex objects to Java" New topic
Author

Passing Flex objects to Java

Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
I have populated a grid using the following

however when I send data back to the java layer it takes it up as asobject even though I have binded the objects.

I have already binded the objects as

Do i have to manually traverse through the dataprovider and make it a YearDepartment.as object for Java to recognize this.

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No, you shouldn't. It suggests there is something wrong with your binding layer. Nothing obvious from the code you've posted I'm afraid.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
I should have mentioned that the object was a hibernate object. Need to check if a basic hibernate object with no mapping would bind. Will let you know soon...

Also, I always though that Flex would not bind transient objects declared in the flex side but looks like hibernate transient objects would also not bind.

More of a design question, how can I send a variable like a String to the Flex side without declaring it as a transient variable wherein hibernate wouldn't try to serialize it.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


I should have mentioned that the object was a hibernate object. Need to check if a basic hibernate object with no mapping would bind. Will let you know soon...

What is different about a "Hibernate" object? Hibernate is designed to work with plain old Java objects.


Also, I always though that Flex would not bind transient objects declared in the flex side but looks like hibernate transient objects would also not bind.

Given you are serializing objects to pass them across the wire, how could you use transient variables?


how can I send a variable like a String to the Flex side without declaring it as a transient variable wherein hibernate wouldn't try to serialize it.

Hibernate won't serialize it - Hibernate doesn't serialize anything. Hibernate will persist mapped fields. If you don't map the field, Hibernate won't do anything with it?
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
Yep, your right its just a pojo and I am able to bind it when it a simple hibernate object.

My problem is that this hibernate object (A) has a onetomany (an arraylist C) and I am not able to map this.



Is there a way for me to access the object at the 0th position without using actionscript
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What type is C? In ActionScript, ArrayCollections can be bound, Arrays can't.
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
It is an arraycollection and the data binds perfectly well. I am just unable to display a variable inside the arraycollection in the datagrid without using actionscript.

I have fixed it but it looks ugly (atleast to me). I have defined an object D in the Flex side alone and have got actionscript to set D as position 0 of the arraycollection C (since I only need the first object).
Lot of unwanted looping logic I feel. So now I have -
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Flex objects to Java