2 things; first off, I never figured out why remoting strips the toString() 
method.  OpenAMF & .NET both strip it.

However, your casting is right, and it IS working; it's just the toString() 
is stripped, so when you trace it, it runs toString(), which doesn't exist, 
and returns nothing, thus it shows null.

So, if you're Object.registerClass is done correctly, you should see:

var re:ValueObject = ValueObject(result.result);
trace(re instanceof ValueObject); // true

----- Original Message ----- 
From: "Bas van Gils" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, November 18, 2005 11:06 AM
Subject: [osflash] openAMF ValueObject problem


Hi,

I have a problem getting a ValueObject to the client from a service
using openAMF.

The situation:
When the responder.onResult(re: ResultEvent) function is executed after
a service call, I want to cast the value of re.result to a ValueObject.
This is done by:
--------------------------------
var vo : ValueObject = ValueObject(re.result);
--------------------------------

Now, when I try to trace the vo variable, "null" is traced, whichs means
that the cast has failed (according to the Flash docs). But when I trace
all properties of the re.result with:
--------------------------------
for (var p in re.result)
{
trace("re.result["+p+"] == "+re.result[p]);
}
--------------------------------

... I see that the id-property is correctly filled with a value of 12
(see the id property in the java-class below), so it looks like openAMF
has correctly serialized the java-ValueObject to AMF, but the Flash
Player cannot cast the re.result to a ValueObject.

Does anyone have an explanation why this is happening?
I'm ColdFusion Standard. Is that that problem? Should I be using the
J2EE version?

Ofcourse I added the mapping in "openamf-config.xml"

<custom-class-mapping>
<java-class>test.server.vo.ValueObject</java-class>
<custom-class>test.client.vo.ValueObject</custom-class>
</custom-class-mapping>



my ActionScript-class:
--------------------------------------------------------
class test.client.vo.ValueObject
{
private static var registered : Boolean =
Object.registerClass("test.server.vo.ValueObject", ValueObject);

private var id : Number = 12; // NOTE: 12 is just for testing!

public function ValueObject()
{
trace("ValueObject.constructor()");
}

public function getId() : Number
{
return this.id;
}

public function setId(id: Number) : Void
{
this.id = id;
}
}
---------------------------------------------------------

my Java-class:
---------------------------------------------------------
package test.server.vo.ValueObject;

import java.io.Serializable;

public class ValueObject implements Serializable
{
public Integer id;

public ValueObject()
{
}

public Integer getId()
{
return this.id;
}

public void setId(Integer id)
{
this.id = id;
}
}
---------------------------------------------------------


Thanks!

Bas.


PS.
I found a workaround by passing the re.result variable to the
constructor of the AS ValueObject and then copying the properties of the
re.result to the class-properties of the ValueObject, but I do not
prefer this "solution".

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org 


_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to