Anyone has some comments on this?
-----Oorspronkelijk bericht----- Van: Bas van Gils [mailto:[EMAIL PROTECTED] Namens Bas van Gils Verzonden: donderdag 24 november 2005 19:14 Aan: Open Source Flash Mailing List Onderwerp: RE: [osflash] openAMF ValueObject problem well, I finally got it working. It seems that you have to use the same packagename for the ActionScript-class as for the Java-class. When I changed this, it worked right away! I looked into sourcecode of the openAMF AMFSerializer-class (writeObject method) and I found at one point that it writes the custom-class (which contains the ActionScript packagename) to the outputstream but in my point of view it should write the java-class. So I changed this behaviour in my project so I can use different packagenames, but I can't explain why this is happening. I guess I'm not the only one using different packagenames client-side and server-side. Am I overlooking something here? -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] namens JesterXL Verzonden: vr 18-11-2005 22:41 Aan: Open Source Flash Mailing List CC: Onderwerp: Re: [osflash] openAMF ValueObject problem Another thing I do differently, and only saying this because it worked, is putting your Object.registerClass calls in a totally different class, that gets called at least 1 frame after frame 1. Additionally, using the whole classpath. Object.registerClass("com.company.project.model.vo.ValueObject", com.company.project.model.vo.ValueObject); For example. ----- Original Message ----- From: "Bas van Gils" <[EMAIL PROTECTED]> To: "Open Source Flash Mailing List" <[email protected]> Sent: Friday, November 18, 2005 4:13 PM Subject: Re: [osflash] openAMF ValueObject problem Hi JesterXL, the actual ValueObject AS-classes in my project do contain a toString() method I added manually, but still "null" is traced after casting. I have tried testing instanceof before casting the result (which returns false) but not after. I will try that! Thanks. But I also noticed this: when I don't cast the result: a trace of vo.id shows the actual id-value, when I do cast the result: a trace of vo.id shows "undefined". This looks like the cast messes up the object. The same happens when I trace "vo.toString" (without brackets), it should trace something like [Function], but when the result is casted it shows "undefined". Bas. -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] namens JesterXL Verzonden: vr 18-11-2005 19:21 Aan: Open Source Flash Mailing List CC: Onderwerp: Re: [osflash] openAMF ValueObject problem 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 ------------------------------------------------------------------------ -------- _______________________________________________ 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 _______________________________________________ osflash mailing list [email protected] http://osflash.org/mailman/listinfo/osflash_osflash.org
