Re: [flexcoders] how to de-serialize objects

2008-12-02 Thread freak182

Hello,
I have similar problem and im totally new to flex and cairngorm... here is
my code snippet:

im my java end:

 ListUsers getAll() {  // from hibernate dao then return result which
llist of users }

in AS files:

public class ListDelegate extends EventDispatcher
{
private var userService:RemoteObject;
private var responder:IResponder;

public function ListDelegate(responder:IResponder)
{
this.userService = new  RemoteObject(userService);

this.responder = responder;
}

public function getUserList():void
{

var call : Object = userService.getAll();

call.addResponder( responder );

}
}


public class ListUserCommand extends BaseCommand
{


override protected function callDelegate():void
{
var listdelegate:ListDelegate = new ListDelegate(this);
listdelegate.getUserList();
}

override public function result( event : Object ) : void
{   
this.modelHelper.onResultUser(event);   

}   

override public function fault( event : Object ) : void
{
var faultevt:FaultEvent = event as FaultEvent;
Alert.show(faultevt.fault.rootCause.toString());
}

}

public class ModelHelper
{
[Bindable]
public var userlist: UserList;

public function ModelHelper(userlist: UserList)
{
this.userlist = userlist;
}

public function getUserList():void
{
new ListUserEvent(this).dispatch();
}

public function onResultUser(event:Object):void
{
this.userlist.listusers = event.result as 
ArrayCollection;
}

}

..and i use DataGrid to display datas:

?xml version=1.0 encoding=utf-8?
mx:VBox xmlns:mx=http://www.adobe.com/2006/mxml; 
initialize=init()
creationComplete=loadAll() 

mx:Script
![CDATA[
import com.test.flex.util.UserList;
import mx.rpc.events.ResultEvent;
import com.test.flex.model.ViewModelLocator;
import com.test.flex.events.ListUserEvent;
import com.test.flex.model.ModelHelper;

[Bindable]
private var modelLocator:ViewModelLocator =
ViewModelLocator.getInstance();

[Bindable]
public var modelHelper:ModelHelper;
[Bindable]
public var users:UserList;

public function init():void
{
this.users = new UserList();
this.modelHelper = new ModelHelper(users);  

}

public function loadAll():void
{
this.modelHelper.getUserList(); 
}



]]
 /mx:Script
 
 !-- mx:Label text={modelLocator.test}/ --
 
 mx:DataGrid id=userlist dataProvider={modelHelper.userlist.listusers}
mx:columns
mx:DataGridColumn headerText=ID dataField=id/
mx:DataGridColumn headerText=Username dataField=username/
mx:DataGridColumn headerText=Password dataField=password/
/mx:columns
 /mx:DataGrid
 

mx:Button id=logout label=LogOut
click={modelLocator.modelWorkflowState = ViewModelLocator.LOGIN_SCREEN}/
/mx:VBox

..and the rest are straigthforward code. When I change the return value to
String it works fine nut when put it back to List it display nothing or
error i get but when i debug it i gets the results:

11:20:14,459 INFO  [STDOUT] Hibernate: select this_.ID as ID1_0_,
this_.USERNAME as USERNAME1_0_, this_.PASSWORD as PASSWORD1_0_ from user
this_
11:20:14,464 INFO  [STDOUT] [BlazeDS]12/02/2008 [DEBUG] [Service.Remoting]
Adapter 'java-object' called 'userService.getAll(java.util.Arrays$ArrayList
(Collection size:0)
)'
11:20:14,465 INFO  [STDOUT] [BlazeDS]12/02/2008 [DEBUG] [Service.Remoting]
Result: 'java.util.ArrayList (Collection size:2)
  [0] = com.test.flex.model.User
id = 1
username = eman

Re: [flexcoders] how to de-serialize objects -- SOLVED

2008-02-21 Thread [p e r c e p t i c o n]
finally figured this out...so the problem is with using a different
constructor than the AS3 object...originally i passeed the params into the
java object's constructor, but those values were null when they got to the
client so i created accessor methods and called the default constructor and
it worked...sheesh!
p

On Wed, Feb 20, 2008 at 11:28 AM, [p e r c e p t i c o n] 
[EMAIL PROTECTED] wrote:

 just noticed that the namespaces are different...would this matter? on the
 POJO it com.xxx.remoting, but on the AS3Object it just package...
 percy


 On Wed, Feb 20, 2008 at 10:12 AM, [p e r c e p t i c o n] 
 [EMAIL PROTECTED] wrote:

  Hi Again,
  Ok...so by instantiating my class the Serialization took place and there
  are 99 elements of that type in the result...however the members of the
  class are all null, but i'm printing them to a file on the Java side so I
  know that there are values in each object...any ideas on why this is
  happening?
 
  thanks so much for all your input!
  percy
 




Re: [flexcoders] how to de-serialize objects

2008-02-20 Thread Sujit Reddy
Hi,
Firstly you need to map your AS objects to the Java objects (if you did this
already, ignore). Here is the link to details on how to map.
http://sujitreddyg.wordpress.com/2008/01/16/mapping-action-script-objects-to-java-objects/

to which component are you setting the dataprovider to? if it is DataGrid,
can you make sure you have included the datafield properties properly. If it
is to List or combobox, you have to set the label field property also.

If all the above are done and still it is not working, please share some
code snippets, which might help to debug the issue.

Regards,
Sujit Reddy G

On Wed, Feb 20, 2008 at 11:03 AM, Peeyush Tuli [EMAIL PROTECTED] wrote:

   Are you sure about the code where you set the dataprovider to be 100%
 correct as I have never encountered such a scenario of no serialization.

 One quick recall i have is that flex was not able to de-serialize date
 types
 when used with a dotnet webservice,
  it rather takes them as a string.

 Can you let us know the communication mechanism you are using for this?
 ( webservices or remoting)

 Regarding a serializing utility, maybe this post can help you
 http://www.darronschall.com/weblog/archives/000247.cfm

 ~Peeyush






 On Feb 20, 2008 5:16 AM, [p e r c e p t i c o n] [EMAIL PROTECTED]
 wrote:

hI experts,
  i've created a Java Object that returns an array list of items to my
  flex app...however even though I set the dataprovider attribute correctly
  none of the data actually renders...a quick glance at the data using the
  debugger shows that the objects are there so i think they'renot being
  deserialized properly...can anyone tell me how to achieve this?  i've
  created the client side object in AS, but still not sure why it's not
  working...
  thanks
 
  p
 
  btw i'm using FB3
 
  cheers
 
 
  




-- 
Regards,
Sujit Reddy. G


Re: [flexcoders] how to de-serialize objects

2008-02-20 Thread [p e r c e p t i c o n]
Sujit,
I've done exactly as you have in this blog with the exception of returning
one object at a time...instead i return a list of objects (in java List
resultList = new ArrayList();) .. so i guess i need a way to deserialize the
list on the Actionscript side is that the problem?

yes...i'm using datagrid...

Thanks!

p

On Feb 20, 2008 6:04 AM, Sujit Reddy [EMAIL PROTECTED] wrote:

   Hi,
 Firstly you need to map your AS objects to the Java objects (if you did
 this already, ignore). Here is the link to details on how to map.

 http://sujitreddyg.wordpress.com/2008/01/16/mapping-action-script-objects-to-java-objects/

 to which component are you setting the dataprovider to? if it is DataGrid,
 can you make sure you have included the datafield properties properly. If it
 is to List or combobox, you have to set the label field property also.

 If all the above are done and still it is not working, please share some
 code snippets, which might help to debug the issue.

 Regards,
 Sujit Reddy G


 On Wed, Feb 20, 2008 at 11:03 AM, Peeyush Tuli [EMAIL PROTECTED]
 wrote:

Are you sure about the code where you set the dataprovider to be 100%
  correct as I have never encountered such a scenario of no serialization.
 
  One quick recall i have is that flex was not able to de-serialize date
  types
  when used with a dotnet webservice,
   it rather takes them as a string.
 
  Can you let us know the communication mechanism you are using for this?
  ( webservices or remoting)
 
  Regarding a serializing utility, maybe this post can help you
  http://www.darronschall.com/weblog/archives/000247.cfm
 
  ~Peeyush
 
 
 
 
 
 
  On Feb 20, 2008 5:16 AM, [p e r c e p t i c o n] [EMAIL PROTECTED]
  wrote:
 
 hI experts,
   i've created a Java Object that returns an array list of items to my
   flex app...however even though I set the dataprovider attribute correctly
   none of the data actually renders...a quick glance at the data using the
   debugger shows that the objects are there so i think they'renot being
   deserialized properly...can anyone tell me how to achieve this?  i've
   created the client side object in AS, but still not sure why it's not
   working...
   thanks
  
   p
  
   btw i'm using FB3
  
   cheers
  
  
 


 --
 Regards,
 Sujit Reddy. G
 



Re: [flexcoders] how to de-serialize objects

2008-02-20 Thread [p e r c e p t i c o n]
Peeyush,
I'm using remoting (RemoteObject) with a j2ee back-end...
 it rather takes them as a string.
hmmm...this actually sheds some light on things...i'm not returning the
actual object but rather a list of objects..

thanks
p

On Feb 19, 2008 9:33 PM, Peeyush Tuli [EMAIL PROTECTED] wrote:

   Are you sure about the code where you set the dataprovider to be 100%
 correct as I have never encountered such a scenario of no serialization.

 One quick recall i have is that flex was not able to de-serialize date
 types
 when used with a dotnet webservice,
  it rather takes them as a string.

 Can you let us know the communication mechanism you are using for this?
 ( webservices or remoting)

 Regarding a serializing utility, maybe this post can help you
 http://www.darronschall.com/weblog/archives/000247.cfm

 ~Peeyush






 On Feb 20, 2008 5:16 AM, [p e r c e p t i c o n] [EMAIL PROTECTED]
 wrote:

hI experts,
  i've created a Java Object that returns an array list of items to my
  flex app...however even though I set the dataprovider attribute correctly
  none of the data actually renders...a quick glance at the data using the
  debugger shows that the objects are there so i think they'renot being
  deserialized properly...can anyone tell me how to achieve this?  i've
  created the client side object in AS, but still not sure why it's not
  working...
  thanks
 
  p
 
  btw i'm using FB3
 
  cheers
 
 
  



Re: [flexcoders] how to de-serialize objects

2008-02-20 Thread [p e r c e p t i c o n]
Hi Again,
Ok...so by instantiating my class the Serialization took place and there are
99 elements of that type in the result...however the members of the class
are all null, but i'm printing them to a file on the Java side so I know
that there are values in each object...any ideas on why this is happening?

thanks so much for all your input!
percy


Re: [flexcoders] how to de-serialize objects

2008-02-20 Thread [p e r c e p t i c o n]
just noticed that the namespaces are different...would this matter? on the
POJO it com.xxx.remoting, but on the AS3Object it just package...
percy

On Wed, Feb 20, 2008 at 10:12 AM, [p e r c e p t i c o n] 
[EMAIL PROTECTED] wrote:

 Hi Again,
 Ok...so by instantiating my class the Serialization took place and there
 are 99 elements of that type in the result...however the members of the
 class are all null, but i'm printing them to a file on the Java side so I
 know that there are values in each object...any ideas on why this is
 happening?

 thanks so much for all your input!
 percy



Re: [flexcoders] how to de-serialize objects

2008-02-20 Thread Sujit Reddy
If you are mapping the AS object to the Java class using the RemoteClass
metatag, that will do the work. just make sure the name of the Java class in
the RemoteClass metatag has the fully qualified name i.e. com.xxx.remoting
.classname

You need not de-serialize the arraylist, if the mapped objects are passed in
the ArrayList from Java, you get them as the objects in ArrayCollection in
AS.

did you include the reference to the AS object mapped to the Java object in
you main application file? if a reference of AS object is not included in
the main application file, then that class definition will not be available
during runtime.

If any of the above suggestions are not helping you, share few code snippets
from your application, we can try to debug the problem.

Regards,
Sujit Reddy G

On Thu, Feb 21, 2008 at 12:58 AM, [p e r c e p t i c o n] 
[EMAIL PROTECTED] wrote:

   just noticed that the namespaces are different...would this matter? on
 the POJO it com.xxx.remoting, but on the AS3Object it just package...
 percy


 On Wed, Feb 20, 2008 at 10:12 AM, [p e r c e p t i c o n] 
 [EMAIL PROTECTED] wrote:

  Hi Again,
  Ok...so by instantiating my class the Serialization took place and there
  are 99 elements of that type in the result...however the members of the
  class are all null, but i'm printing them to a file on the Java side so I
  know that there are values in each object...any ideas on why this is
  happening?
 
  thanks so much for all your input!
  percy
 

  




-- 
Regards,
Sujit Reddy. G


[flexcoders] how to de-serialize objects

2008-02-19 Thread [p e r c e p t i c o n]
hI experts,
i've created a Java Object that returns an array list of items to my flex
app...however even though I set the dataprovider attribute correctly none of
the data actually renders...a quick glance at the data using the debugger
shows that the objects are there so i think they'renot being deserialized
properly...can anyone tell me how to achieve this?  i've created the client
side object in AS, but still not sure why it's not working...
thanks

p

btw i'm using FB3

cheers


Re: [flexcoders] how to de-serialize objects

2008-02-19 Thread Peeyush Tuli
Are you sure about the code where you set the dataprovider to be 100%
correct as I have never encountered such a scenario of no serialization.

One quick recall i have is that flex was not able to de-serialize date types
when used with a dotnet webservice,
 it rather takes them as a string.

Can you let us know the communication mechanism you are using for this?
( webservices or remoting)

Regarding a serializing utility, maybe this post can help you
http://www.darronschall.com/weblog/archives/000247.cfm

~Peeyush





On Feb 20, 2008 5:16 AM, [p e r c e p t i c o n] [EMAIL PROTECTED]
wrote:

   hI experts,
 i've created a Java Object that returns an array list of items to my flex
 app...however even though I set the dataprovider attribute correctly none of
 the data actually renders...a quick glance at the data using the debugger
 shows that the objects are there so i think they'renot being deserialized
 properly...can anyone tell me how to achieve this?  i've created the client
 side object in AS, but still not sure why it's not working...
 thanks

 p

 btw i'm using FB3

 cheers