| Author |
Null references for java numbers and flex
|
Morten Franorge
Ranch Hand
Joined: Jul 29, 2005
Posts: 137
|
|
|
In our domain model, having a null value for certain numbers (Integer, Long and Double) have specific business meaning in our domain (different than 0). However, there is no way to represent nulls in action script. They are interpreted as NaN, but once a NaN is sent back to Java, it is not translated back to null. What is the best practise to handle this?
|
SCJP 1.4, SCBCD 1.3, SCBCD 5.0, SCEA J2EE, SCEA 5.0
|
 |
Satish Kore
Author
Ranch Hand
Joined: Feb 10, 2004
Posts: 43
|
|
Hi Morten,
In ActionScript primitive types do not hold null value so anything that is Number,int or uint cannot hold null. Only Object or * type can hold null reference. There are two ways that I can see.
1. Simple approach would be just change type of ActionScript property from Number to Object and then if you assign null, it will be deserialized into null on java side.
2. Try not to use null as valid value, try using -1 or any negative value to represent your meaning.
Thanks,
|
Satish Kore
"Flex 3 with Java" @ packtpub.com and amazon.com
|
 |
Morten Franorge
Ranch Hand
Joined: Jul 29, 2005
Posts: 137
|
|
Satish Kore wrote:Hi Morten,
In ActionScript primitive types do not hold null value so anything that is Number,int or uint cannot hold null. Only Object or * type can hold null reference. There are two ways that I can see.
1. Simple approach would be just change type of ActionScript property from Number to Object and then if you assign null, it will be deserialized into null on java side.
2. Try not to use null as valid value, try using -1 or any negative value to represent your meaning.
Thanks,
Option 2 require me to change the inherit functionality in my domain model, which does not sit well with the DDD. Option 1 makes the action script model sub optimal....hmmmm
|
 |
 |
|
|
subject: Null references for java numbers and flex
|
|
|