RE: [flexcoders] FDS number NaN
First, the behavior of ActionScript 3 Number, int and uint is based on the ECMA Script 4 specification (well, at least what this specification stipulated at the time of release). Given that AS3 has been released Flex is dependent on the way it is today. Second, Java primitives can't be null (they default to 0 if one tries to provide null to them on reflection). So, if you wanted to preserve a null value then your Java propeties would have to use the Object form of the Java numeric types. Third, for ActionScript integer types (i.e. int and uint), and Java integer types (long, int, short, and byte) can not accept NaN. If you try to get the long value from Double.NaN (or Float.NaN) you'll get 0. Fourth, ActionScript Number goes over the wire in AMF3 using the double type and is deserialized as a Java Double. On instantiating your remote Java object or passing a parameter to a method to be invoked this Double is translated to the required type using reflection and translation. So, an ActionScript Number.NaN - Java Double.NaN - Java Long 0 and thus your limitation is that AS numeric types can't be null in general and Java integers can't be NaN. So you need to either use Object in ActionScript to hold null or use Double (or Float) in Java to hold NaN. Pete From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Krueger Sent: Tuesday, December 05, 2006 10:38 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] FDS number NaN Anyone else have this problem or am I just doing something wrong. Thanks Jeff Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there something I am missing or something I need to set the number to so it will be null in my java class? Thanks Jeff
Re: [flexcoders] FDS number NaN
Anyone else have this problem or am I just doing something wrong. Thanks Jeff Jeff Krueger [EMAIL PROTECTED] wrote: I have considered coming up with a number like -99 and then assume that to be null and initialize all my Number variables to it and then translate that in java to null. But that is a hack at best. Anyone else?? Jeff Douglas McCarroll [EMAIL PROTECTED] wrote: Okay. So this is normal FDS behavior, as explained in the docs. The question becomes How can we deal with this limitation of FDS? I don't know an answer but perhaps others on the list do. Has anyone else wished that they could pass NaN or null into Java? How did you deal with this FDS limitation? And perhaps Adobe could comment on whether there's any chance that this behavior will change in the future. Douglas Jeff Krueger wrote: This is correct. My Number in my as class isn't really null it is NaN. But I believe that to be the actionscript equivalent to null for a number. And yes when I pass that to java function that function recieves the class with a 0 for the Long instead of null. Here is the output from the console of the app server. Notice the variable XPos, YPos and deployed. See how what I send in is NaN (or null) and it is converted to a 0. [Flex] Deserializing AMF/HTTP request Version: 3 (Message #0 targetURI=null, responseURI=/2) (Array #0) [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage') operation = findStoryByExample source = null body = (Array #1) [0] = 2 [1] = (Typed Object #2 'com.routeto1.flex.media.vo.StoryVO') headline = c XPos = NaN validToDate = null pageDef = null deployedPath = validFromDate = null subHeadline = storyGraphic = null YPos = NaN keywords = body = source = bylineOccupation = publishedDate = null otherReferences = referenceId = deployed = NaN byline = pk = updatedByUser = null selected = false dateUpdated = null copyForSearch = false createdByUser = null createdByUserName = dateCreated = null clientId = null timeToLive = 0 messageId = A5C134A1-DC44-4514-6B85-43FE21B96CB1 headers = (Object #3) DSEndpoint = my-amf destination = mediaDelegate timestamp = 0 [Flex] Adapter 'java-object' called 'com.routeto1.flex.media.MediaDelegate.findS toryByExample(java.util.Arrays$ArrayList (Collection size:2) [0] = 2 [1] = com.routeto1.flex.media.vo.StoryVO YPos = 0 dateUpdated = null XPos = 0 byline = publishedDate = null dateCreated = null pageDef = null copyForSearch = true validFromDate = null validToDate = null deployedPath = createdByUser = null bylineOccupation = body = headline = c keywords = subHeadline = deployed = 0 referenceId = pk = updatedByUser = null otherReferences = storyGraphic = null createdByUserName = source = )' Thanks Jeff */Douglas McCarroll [EMAIL PROTECTED]/* wrote: Jeff, Let me get this clear. If I understand correctly you're passing an AS number hoping that it will convert to a Java Long. But your number is set to null, and you'd like it to convert to null on the Java type. Is this correct? Douglas Jeff Krueger wrote: Thanks. I am not using a primitive, I am using Long. I wonder what it does for those. Jeff */Douglas McCarroll [EMAIL PROTECTED] mailto:org.yahoo_primary.001%40douglasmccarroll.com/* wrote: Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org http://www.cairngormdocs.org/ http://www.cairngormdocs.org/ http://www.cairngormdocs.org/ Flex Developer http://www.brightworks.com http://www.brightworks.com/ http://www.brightworks.com/ http://www.brightworks.com/ 617.459.3840 - Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there
Re: [flexcoders] FDS number NaN
This is correct. My Number in my as class isn't really null it is NaN. But I believe that to be the actionscript equivalent to null for a number. And yes when I pass that to java function that function recieves the class with a 0 for the Long instead of null. Here is the output from the console of the app server. Notice the variable XPos, YPos and deployed. See how what I send in is NaN (or null) and it is converted to a 0. [Flex] Deserializing AMF/HTTP request Version: 3 (Message #0 targetURI=null, responseURI=/2) (Array #0) [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage') operation = findStoryByExample source = null body = (Array #1) [0] = 2 [1] = (Typed Object #2 'com.routeto1.flex.media.vo.StoryVO') headline = c XPos = NaN validToDate = null pageDef = null deployedPath = validFromDate = null subHeadline = storyGraphic = null YPos = NaN keywords = body = source = bylineOccupation = publishedDate = null otherReferences = referenceId = deployed = NaN byline = pk = updatedByUser = null selected = false dateUpdated = null copyForSearch = false createdByUser = null createdByUserName = dateCreated = null clientId = null timeToLive = 0 messageId = A5C134A1-DC44-4514-6B85-43FE21B96CB1 headers = (Object #3) DSEndpoint = my-amf destination = mediaDelegate timestamp = 0 [Flex] Adapter 'java-object' called 'com.routeto1.flex.media.MediaDelegate.findS toryByExample(java.util.Arrays$ArrayList (Collection size:2) [0] = 2 [1] = com.routeto1.flex.media.vo.StoryVO YPos = 0 dateUpdated = null XPos = 0 byline = publishedDate = null dateCreated = null pageDef = null copyForSearch = true validFromDate = null validToDate = null deployedPath = createdByUser = null bylineOccupation = body = headline = c keywords = subHeadline = deployed = 0 referenceId = pk = updatedByUser = null otherReferences = storyGraphic = null createdByUserName = source = )' Thanks Jeff Douglas McCarroll [EMAIL PROTECTED] wrote: Jeff, Let me get this clear. If I understand correctly you're passing an AS number hoping that it will convert to a Java Long. But your number is set to null, and you'd like it to convert to null on the Java type. Is this correct? Douglas Jeff Krueger wrote: Thanks. I am not using a primitive, I am using Long. I wonder what it does for those. Jeff */Douglas McCarroll [EMAIL PROTECTED]/* wrote: Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org http://www.cairngormdocs.org/ Flex Developer http://www.brightworks.com http://www.brightworks.com/ 617.459.3840 - Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there something I am missing or something I need to set the number to so it will be null in my java class? Thanks Jeff -- Access over 1 million songs - Yahoo! Music Unlimited. http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/ http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/ -- Want to start your own business? Learn how on Yahoo! Small Business. http://us.rd.yahoo.com/evt=41244/*http://smallbusiness.yahoo.com/r-index - Everyone is raving about the all-new Yahoo! Mail beta.
Re: [flexcoders] FDS number NaN
Okay. So this is normal FDS behavior, as explained in the docs. The question becomes How can we deal with this limitation of FDS? I don't know an answer but perhaps others on the list do. Has anyone else wished that they could pass NaN or null into Java? How did you deal with this FDS limitation? And perhaps Adobe could comment on whether there's any chance that this behavior will change in the future. Douglas Jeff Krueger wrote: This is correct. My Number in my as class isn't really null it is NaN. But I believe that to be the actionscript equivalent to null for a number. And yes when I pass that to java function that function recieves the class with a 0 for the Long instead of null. Here is the output from the console of the app server. Notice the variable XPos, YPos and deployed. See how what I send in is NaN (or null) and it is converted to a 0. [Flex] Deserializing AMF/HTTP request Version: 3 (Message #0 targetURI=null, responseURI=/2) (Array #0) [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage') operation = findStoryByExample source = null body = (Array #1) [0] = 2 [1] = (Typed Object #2 'com.routeto1.flex.media.vo.StoryVO') headline = c XPos = NaN validToDate = null pageDef = null deployedPath = validFromDate = null subHeadline = storyGraphic = null YPos = NaN keywords = body = source = bylineOccupation = publishedDate = null otherReferences = referenceId = deployed = NaN byline = pk = updatedByUser = null selected = false dateUpdated = null copyForSearch = false createdByUser = null createdByUserName = dateCreated = null clientId = null timeToLive = 0 messageId = A5C134A1-DC44-4514-6B85-43FE21B96CB1 headers = (Object #3) DSEndpoint = my-amf destination = mediaDelegate timestamp = 0 [Flex] Adapter 'java-object' called 'com.routeto1.flex.media.MediaDelegate.findS toryByExample(java.util.Arrays$ArrayList (Collection size:2) [0] = 2 [1] = com.routeto1.flex.media.vo.StoryVO YPos = 0 dateUpdated = null XPos = 0 byline = publishedDate = null dateCreated = null pageDef = null copyForSearch = true validFromDate = null validToDate = null deployedPath = createdByUser = null bylineOccupation = body = headline = c keywords = subHeadline = deployed = 0 referenceId = pk = updatedByUser = null otherReferences = storyGraphic = null createdByUserName = source = )' Thanks Jeff */Douglas McCarroll [EMAIL PROTECTED]/* wrote: Jeff, Let me get this clear. If I understand correctly you're passing an AS number hoping that it will convert to a Java Long. But your number is set to null, and you'd like it to convert to null on the Java type. Is this correct? Douglas Jeff Krueger wrote: Thanks. I am not using a primitive, I am using Long. I wonder what it does for those. Jeff */Douglas McCarroll [EMAIL PROTECTED] mailto:org.yahoo_primary.001%40douglasmccarroll.com/* wrote: Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org http://www.cairngormdocs.org/ http://www.cairngormdocs.org/ http://www.cairngormdocs.org/ Flex Developer http://www.brightworks.com http://www.brightworks.com/ http://www.brightworks.com/ http://www.brightworks.com/
Re: [flexcoders] FDS number NaN
I have considered coming up with a number like -99 and then assume that to be null and initialize all my Number variables to it and then translate that in java to null. But that is a hack at best. Anyone else?? Jeff Douglas McCarroll [EMAIL PROTECTED] wrote: Okay. So this is normal FDS behavior, as explained in the docs. The question becomes How can we deal with this limitation of FDS? I don't know an answer but perhaps others on the list do. Has anyone else wished that they could pass NaN or null into Java? How did you deal with this FDS limitation? And perhaps Adobe could comment on whether there's any chance that this behavior will change in the future. Douglas Jeff Krueger wrote: This is correct. My Number in my as class isn't really null it is NaN. But I believe that to be the actionscript equivalent to null for a number. And yes when I pass that to java function that function recieves the class with a 0 for the Long instead of null. Here is the output from the console of the app server. Notice the variable XPos, YPos and deployed. See how what I send in is NaN (or null) and it is converted to a 0. [Flex] Deserializing AMF/HTTP request Version: 3 (Message #0 targetURI=null, responseURI=/2) (Array #0) [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage') operation = findStoryByExample source = null body = (Array #1) [0] = 2 [1] = (Typed Object #2 'com.routeto1.flex.media.vo.StoryVO') headline = c XPos = NaN validToDate = null pageDef = null deployedPath = validFromDate = null subHeadline = storyGraphic = null YPos = NaN keywords = body = source = bylineOccupation = publishedDate = null otherReferences = referenceId = deployed = NaN byline = pk = updatedByUser = null selected = false dateUpdated = null copyForSearch = false createdByUser = null createdByUserName = dateCreated = null clientId = null timeToLive = 0 messageId = A5C134A1-DC44-4514-6B85-43FE21B96CB1 headers = (Object #3) DSEndpoint = my-amf destination = mediaDelegate timestamp = 0 [Flex] Adapter 'java-object' called 'com.routeto1.flex.media.MediaDelegate.findS toryByExample(java.util.Arrays$ArrayList (Collection size:2) [0] = 2 [1] = com.routeto1.flex.media.vo.StoryVO YPos = 0 dateUpdated = null XPos = 0 byline = publishedDate = null dateCreated = null pageDef = null copyForSearch = true validFromDate = null validToDate = null deployedPath = createdByUser = null bylineOccupation = body = headline = c keywords = subHeadline = deployed = 0 referenceId = pk = updatedByUser = null otherReferences = storyGraphic = null createdByUserName = source = )' Thanks Jeff */Douglas McCarroll [EMAIL PROTECTED]/* wrote: Jeff, Let me get this clear. If I understand correctly you're passing an AS number hoping that it will convert to a Java Long. But your number is set to null, and you'd like it to convert to null on the Java type. Is this correct? Douglas Jeff Krueger wrote: Thanks. I am not using a primitive, I am using Long. I wonder what it does for those. Jeff */Douglas McCarroll [EMAIL PROTECTED] mailto:org.yahoo_primary.001%40douglasmccarroll.com/* wrote: Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org http://www.cairngormdocs.org/ http://www.cairngormdocs.org/ http://www.cairngormdocs.org/ Flex Developer http://www.brightworks.com http://www.brightworks.com/ http://www.brightworks.com/ http://www.brightworks.com/ 617.459.3840 - Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there something I am missing or something I need to set the number to so it will be null in my java class? Thanks Jeff
Re: [flexcoders] FDS number NaN
Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org Flex Developer http://www.brightworks.com 617.459.3840 - Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there something I am missing or something I need to set the number to so it will be null in my java class? Thanks Jeff Access over 1 million songs - Yahoo! Music Unlimited. http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/
Re: [flexcoders] FDS number NaN
Thanks. I am not using a primitive, I am using Long. I wonder what it does for those. Jeff Douglas McCarroll [EMAIL PROTECTED] wrote: Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org Flex Developer http://www.brightworks.com 617.459.3840 - Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there something I am missing or something I need to set the number to so it will be null in my java class? Thanks Jeff -- Access over 1 million songs - Yahoo! Music Unlimited. http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/ - Want to start your own business? Learn how on Yahoo! Small Business.
Re: [flexcoders] FDS number NaN
Jeff, Let me get this clear. If I understand correctly you're passing an AS number hoping that it will convert to a Java Long. But your number is set to null, and you'd like it to convert to null on the Java type. Is this correct? Douglas Jeff Krueger wrote: Thanks. I am not using a primitive, I am using Long. I wonder what it does for those. Jeff */Douglas McCarroll [EMAIL PROTECTED]/* wrote: Jeff, I'm not sure that this will help you find a solution, but it confirms that this is a known issue: http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_GetStarted.html Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java object, Flex interprets null values as the default for primitive types; for example, 0 for double, float, long, int, short, byte, \u for char, and false for Boolean. Only primitive Java types get default values. Douglas - Douglas McCarroll CairngormDocs.org Webmaster http://www.CairngormDocs.org http://www.cairngormdocs.org/ Flex Developer http://www.brightworks.com http://www.brightworks.com/ 617.459.3840 - Jeff Krueger wrote: All, I am finding that when I pass a actionscript class to a remote java object and a number variable type in the actionscript class is set to NaN (Null), that the java class gets set to a 0, instead of a null. Is there something I am missing or something I need to set the number to so it will be null in my java class? Thanks Jeff -- Access over 1 million songs - Yahoo! Music Unlimited. http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/ http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/ Want to start your own business? Learn how on Yahoo! Small Business. http://us.rd.yahoo.com/evt=41244/*http://smallbusiness.yahoo.com/r-index