Reported in Feb, still listed as new, so make sure you vote:

http://code.google.com/p/google-web-toolkit/issues/detail?id=4646

On Aug 3, 1:07 am, Andrew Hughes <ahhug...@gmail.com> wrote:
> Fixed... but I think this stinks :)
>
>     public final Double getXMin(){
>         return isXMinNull() ? null : getXMinValue();
>     }
>
>     private final native boolean isXMinNull()/*-{
>         return this.xmin == null;
>     }-*/;
>
>     private final native double getXMinValue()/*-{
>         return this.xmin;
>     }-*/;
>
> On Tue, Aug 3, 2010 at 11:50 AM, Andrew Hughes <ahhug...@gmail.com> wrote:
> > Thank's again André :)
>
> > I've made some progress..... you'r suggestion to use Integer and not
> > primitive int was bang on the mark! :) Unfornately autoboxing was masking
> > some of my problems - but now I have learnt the error's of my ways :)
>
> > Now I am happily using Integer with and without null values...
>
> >     public final native Integer getCode()/*-{
> >         return this.code;
> >     }-*/;
>
> > HOWEVER, Double && double won't work. Double works with null but not a
> > valid javascript Number... and vice-a-vera with double. I've looked at all
> > the documentation... going crazy to tell you the truth over such a small
> > simple issue.. but your helps been great THANK YOU! :)
>
> > --AH
>
> > 2010/8/3 André Moraes <andr...@gmail.com>
>
> >  1) This HostedModeException is very annoying. Null (or in JavaScript
> >>> terms 'undefined') is a valid value for my JavaScript/JSON attributes. I
> >>> want a way where if the darn thing is undefined return null... don't throw
> >>> a HostedModeException  - I also tried in jsni if(this.attribute){ return
> >>> this.attribute; } else { return undefined } but the exception is still
> >>> thrown.
>
> >> in your Jsni instead of
>
> >> if (this.attribute) { return this.attribute; } else { return undefined; }
>
> >> try
>
> >> if (this.attribute) { return this.attribute; } else { return null; }
>
> >> In javascript, null and undefined are two differente things. When
> >> something is null, this means that an variable is defined and its value is
> >> null; If something is undefined that means there is no variable with that
> >> name.
>
> >> the statment: "if (this.attribute)" works because when in a boolean
> >> context, undefined is evaluated to false. Just like C where 0 is false and
> >> everything else is true.
>
> >> To solve the int problem, try to change the return type to "Object" and
> >> then check if the returned value is null. There is no way to return "null"
> >> in java if the return type of a method is a "primitive int";
>
> >> I belive that since you are returning null from JSNI, the HostedMode will
> >> be smart enough to cast "javascript null" to "java null". :)
>
> >>> 2) There is no documentation about how this will behave in production?
> >>> Will it just return null? I don't know how I can ensure consistency 
> >>> between
> >>> dev and production modes :'(
>
> >> In production mode the javascript rules applies, so this probably will
> >> trigger an error in your browser. When using JSNI method is necessary to
> >> think in two different worlds (java and javascript). Check this link, maybe
> >> will help with the javascript type system:
> >>http://www.java2s.com/Tutorial/JavaScript/0100__Number-Data-Type/Prim...
>
> >> Hope it helps.
> >> --
> >> André Moraes
> >> Analista de Desenvolvimento de Sistemas
> >> andr...@gmail.com
> >>http://andredevchannel.blogspot.com/
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Google Web Toolkit" group.
> >> To post to this group, send email to google-web-tool...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-web-toolkit?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to