Remember that RemoteObject calls are
asynchronous. So what you're getting back in AS from the mySrv.getDebate(1)
is actually the call object. If you remember from the docs you might have
seen something like this:
var call = mySrv.getDebate(1);
call.sometoken = "foo";
Then in your result handler you might say:
function handler(event)
{
var sometoken = event.call.sometoken;
if (sometoken == "foo")
//do something foo related with event.result
else if (sometoken == "bar")
//do something bar related with event.result
...
}
So if you didn't need to worry about
synching up the call don't do anything with what's returned from that
method.
Make sense?
Matt
-Original Message-
From: brian_r_christian
[mailto:[EMAIL PROTECTED]
Sent: Sunday, May 09, 2004 6:11 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re:
Populating a Tree at Runtime with a org.w3c. dom. Document
Ok, that's working alright, but we're having
another related issue.
I've put the code below, but it seems like when we
import the result
of a remote java method which returns a string,
it's being displayed
as simply [object Object]. However, when we
bind TextAreas to
{myServ.theMethod.result}, they display the
correct contents of the
string the method returns.
In the following example, area1
displays the correct string, while
area2 displays [object
Object]. What are we doing incorrectly?
(Big picture wise, we're looking to parse this
string and populate a
tree with it. Don't know if that information
is useful to you or not.)
Thanks!
Brian
?xml version=1.0
encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml
mx:Script
![CDATA[
function retrieveDebate() {
var debateString:String;
debateString = mySrv.getDebate(1);
area2.text = debateString;
}
]]
/mx:Script
mx:RemoteObject id=mySrv
source=ghaley.backend.DebateBackend
/mx:RemoteObject
mx:Button id=maketreebutton label=Get Debate
click=this.retrieveDebate() /
mx:TextArea id=area1
text={mySrv.getDebate.result}/
mx:TextArea id=area2 /
/mx:Application
--- In flexcoders@yahoogroups.com, Matt Chotin
[EMAIL PROTECTED] wrote:
AS, unlike Java, does not allow you to assign
instance variables as
part of
their declarations. So you'll need to
move that code into a method
and then
call that method from your initialize
handler.
?xml version=1.0
encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml
http://www.macromedia.com/2003/mxml
initialize=setup()
mx:Script
![CDATA[
import mx.utils.*;
var xmlTest:XML;
function setup()
{
var stringTest:String = allnodesnode label='Option
1'node label='Option
1.1'/node label='Option 1.2'//nodenode
label='Option 2'//allnodes;
xmlTest = mx.utils.XMLUtil.createXML(stringTest);
}
]]
/mx:Script
mx:Tree
mx:dataProvider
{xmlTest}
/mx:dataProvider
/mx:Tree
/mx:Application
-Original Message-
From: brian_r_christian
[mailto:[EMAIL PROTECTED]
Sent: Sunday, May 09, 2004 4:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Populating a Tree
at Runtime with a
org.w3c.dom.
Document
Matt,
Not sure what you mean about how to have flex
build a tree out of a
tree of objects passed in from
java.
We've tried to convert ActionScript objects
of type String to objects
of type XML, and had some problems:
for example, the code below generates a
A class's instance variables
may only be initialized to compile-time
constant expressions error,
and we're not sure what that means or how to
alleviate it.
Any advice on either front would be greatly
appreciated. Thanks!
Brian
* CODE
*
?xml version=1.0
encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml
http://www.macromedia.com/2003/mxml
mx:Script
![CDATA[
import mx.utils.*;
var stringTest:String = allnodesnode label='Option
1'node label='Option
1.1'/node label='Option 1.2'//nodenode
label='Option 2'//allnodes;
var xmlTest:XML = mx.utils.XMLUtil.createXML(stringTest);
]]
/mx:Script
mx:Tree
mx:dataProvider
{xmlTest}
/mx:dataProvider
/mx:Tree
/mx:Application
--- In flexcoders@yahoogroups.com, Matt
Chotin [EMAIL PROTECTED] wrote:
I played around with this a little today
and realized that
RemoteObject
doesn't support returning a Document
class too nicely because the
Document
implementations (at least the default
crimson version) have circular
references. This is something we
can look to fix in a future
updater. In
the meantime the question is whether you
really want the data
represented as
XML in the first place. If you are
pulling in the data from a
database you
can simply build a tree of objects and return
that to Flex. Flex
can take
those objects and build a tree out of it
as long as you specify the
labelField correctly. If you
already have