开发者

ActionScript: Type coercion problem with BlazeDS/AMF and class interfaces

I've got a problem with type coercion in a Java/Hibernate/BlazeDS/Flex-Setup.

First of all, my classes look like this:


--- JAVA ---

Interface I

(Abstract) Class A implements I

Class B extends A

--- ActionScript ---

Interface I

Class A implements I

Class B extends A


I got RemoteClass-Meta-Tags in all ActionScript-Classes/Interfaces I, A and B. Package structure and Class/Interface names are exactly the same.

Now here's the problem: My Java Service successfully开发者_如何转开发 retrieves objects of class B from my database via Hibernate. I got another class C which has a member property of interface type I, so it should be possible to assign an object of type B. But for some reason i get the following error message:

TypeError: Error #1034: cannot convert Object@28b44a89 to package.name.I

I checked the Java object type in the service and it is of type B and seems to be totally fine. Why can't the object of type B be assigned to a member variable of type I? This is driving me nuts.

Thanks in advance.


Check the type the objects returned by the service call (inspect the result with a debugger in Flash Builder). Maybe they are not properly converted to type B and an ObjectProxy is created. If it's not the case, please post your code.


I got same strange issue.

My situation like this: I develop an web application with Flex 4 + Spring

In Java, I have class Message. In Flex, I have class Message.

When getting remote java object from server and cast to Message type in Flex, this error will occur. The strange thing is that, on the first time, it's OK to cast to Message type in Flex from remote java object and there's no error; but in the second time, it fail and error will be shown.

To solve this, I have one solution: using registerClassAlias() method to register for remote java class.

But I wonder if there's other solution for this issue. Is this a bug of Flex?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜