[flexcoders] Web browser crashing on remote method call

2005-06-13 Thread Kevin Ewok
I've searched previous postings and I cannot find the solution to 
this problem for the life of me.

I am making a remote method call which retrieves an array of 
JavaObjects. Within each JavaObject, i have 5 string attributes, and 
1 attribute that is an array of custom Java Objects. I have narrowed 
down the problem down to this array.

Whenever I preview my mxml object, the web browser hangs and never 
gets past the initialize screen.

I've included my mxml file below. I saw a posting that all the Java 
objects need to have empty construtors. I did that but the browser 
still hangs. I created AS classes and included the static var for 
Object.registerClass, but that did not work for me either. If I 
comment out my array of custom objects in my MainObject(and the 
getter and setters), the datagrid loads fine. Any ideas?

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
xmlns=* pageTitle=Dispatcher initialize=startApp()
mx:Script
 ![CDATA[   
import com.myAsClasses.*;
function startApp()
 {
myobj.findJobs(null); //i can see in a java println data is returned
 }
]]
/mx:Script

mx:RemoteObject source=com.RemoteServiceImpl type=stateless-
class id=myobj
 mx:method name=findJobs /
/mx:RemoteObject
mx:DataGrid id=dg dataProvider={myobj.findJobs.result} 
width=100% height=375 
   mx:columns
 mx:Array
   mx:DataGridColumn columnName=myattr headerText=Attr /
 /mx:Array
   /mx:columns
/mx:DataGrid
  
/mx:Application


My findJobs method return an array...for example MainObject[].

My MainObject has the 5 String attributes and 1 attribute 
SiblingObject[]. In my datagrid I am not even referencing any of 
these attributes so it is failing trying to serialize them.

My MainObject class in Java has:
private SiblingObject[] = siblingObjects;

My MainObject class is AS has: 
var siblingObjects: Array = new Array();


I created my AS classes (using FlexPojo2AS-- 
http://www.meagle.com/FlexPojo2AS/FlexPojo2AS.html), but that did 
not solve my problem. I know the AS classes are OK because I've used 
them before, just never with object graphs before. I'm sorry if this 
is a beat topic, but I haven't seen any posting on the client swf 
file hanging the browser.

Thanks. 





 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




RE: [flexcoders] Web browser crashing on remote method call

2005-06-13 Thread Peter Farland
It sounds like you might be in an infinite loop somewhere on the
client... a common way to get into such a loop is when processing object
graphs with circular references.

From your MXML code listing below (i.e. it shows direct binding of the
RO result as a data provider) I don't see that you're doing any
recursive processing of the result so I'd propose that you've discovered
a bug with DataGrid when bound to object graphs that have circular
references.

How, you might ask, would you have a circular reference in an object
graph from a RemoteObject result? Without seeing any of the code for the
object graph I can only guess that somewhere in your sibling instances
you have a pointer to a parent main object (or perhaps some circular
dependency between sibs, whatever). 

When serializing objects over AMF the client and server will attempt to
restore references between complex objects, for example, Just say we
have two objects, A and B where B has a reference back to its parent A:

A - B - A

RemoteObject will serialize the A property of B as a reference to the
instance A, rather than reserialize A again. This allows the client and
server to support circularly referenced object graphs and avoids
infinite recursion on serialization/deserialization. 

To prove that this is indeed happening you can turn on Debug level
logging for the RemoteObject gateway in the
/WEB-INF/flex/gateway.config.xml file, restart the flex server, and then
watch the server console for AMF traffic, you should be able to see the
by-reference serializaiton entries in the log.

Note that RemoteObject is doing the right thing here - it might just be
that DataGrid can't handle the circularity of the object graph.

Let me know what you find out.

Pete 


 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/