hillolsarker
11-17-2008, 07:38 AM
flex can convert flex-"int" to java-"long" when serialize or deserialize in Remote object. Thats not real problem. Problem arise when converting flex-"Array" to java-"Collection<Long>". It says:
[RPC Fault faultString="java.lang.ClassCastException : java.lang.Integer cannot be cast to java.lang.Long" faultCode="Server.Processing" faultDetail="null"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at NetConnectionMessageResponder/statusHandler()
at mx.messaging::MessageResponder/status()
That means flex always convert flex-"Array" to java-"Collection<Integer>". i cant change the server side code. What i tried so far is telling flex that array is of Number by
[ArrayElementType("Number")]
var longIdsToSend:Array = new Array();
As we know flex-"Number" converts to "java.lang.Double, double", "java.lang.Long, long" and "java.lang.Float, float". So, it won't try to convert to int. Logically it should work. But, it didn't. Same problem.
I tried another thing.
[ArrayElementType("Number")]
var longIdsToSend:Array = new Array();
longIdsToSend.push("some string");
Alert.show(longIdsToSend.toString());
it doesn't do any compile time error. At runtime it alerts the string, which he should not. Another thing is, at server end it tries to map to java-"Collection<String>". Can anybody tell me what is the necessity of ArrayElementType? is there any bug or not in flex 3? or any way around?
[RPC Fault faultString="java.lang.ClassCastException : java.lang.Integer cannot be cast to java.lang.Long" faultCode="Server.Processing" faultDetail="null"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at NetConnectionMessageResponder/statusHandler()
at mx.messaging::MessageResponder/status()
That means flex always convert flex-"Array" to java-"Collection<Integer>". i cant change the server side code. What i tried so far is telling flex that array is of Number by
[ArrayElementType("Number")]
var longIdsToSend:Array = new Array();
As we know flex-"Number" converts to "java.lang.Double, double", "java.lang.Long, long" and "java.lang.Float, float". So, it won't try to convert to int. Logically it should work. But, it didn't. Same problem.
I tried another thing.
[ArrayElementType("Number")]
var longIdsToSend:Array = new Array();
longIdsToSend.push("some string");
Alert.show(longIdsToSend.toString());
it doesn't do any compile time error. At runtime it alerts the string, which he should not. Another thing is, at server end it tries to map to java-"Collection<String>". Can anybody tell me what is the necessity of ArrayElementType? is there any bug or not in flex 3? or any way around?