{"id":632,"date":"2010-09-06T21:07:02","date_gmt":"2010-09-07T03:07:02","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=632"},"modified":"2010-09-06T21:07:02","modified_gmt":"2010-09-07T03:07:02","slug":"avoid-primitive-object-wrappers-as-return-values-for-gwt-javascript-overlays","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/632","title":{"rendered":"Avoid primitive object wrappers as return values for GWT javascript overlays"},"content":{"rendered":"<p>Just a warning, if you build javascript overlay types, you should make sure to only use primitives and strings as primary members of your overlay classes.\u00a0 I&#8217;ve already <a href=\"http:\/\/www.mooreds.com\/wordpress\/archives\/531\">written about overlay types once before<\/a>, and here&#8217;s the <a href=\"http:\/\/code.google.com\/webtoolkit\/doc\/latest\/DevGuideCodingBasicsOverlay.html\">GWT documentation<\/a>.\u00a0 If you dig a bit deeper in the GWT documentation, you see this quote:<\/p>\n<blockquote><p><a href=\"http:\/\/code.google.com\/p\/google-web-toolkit\/wiki\/OverlayTypes\">JavaScript non-string objects <strong>always<\/strong> marshal as <tt>JavaScriptObject$<\/tt><\/a><\/p><\/blockquote>\n<p>I was using a java.lang.Double as the return value for one of my overlay objects, and it was fine until I tried to do any math on it.\u00a0 Nothing would seem to turn the value into a Double or a double, yet no exceptions were thrown.\u00a0 After some sleuthing in web mode, it turned out that the value returned when I was trying to parse it was NaN, even though when I output it to the screen, the value looked like a double.\u00a0 I guess it was being treated as a <code>JavaScriptObject$<\/code>.<\/p>\n<p>Easily enough fixed, just make sure that you don&#8217;t use any objects wrappers of primitives in an overlay type.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a warning, if you build javascript overlay types, you should make sure to only use primitives and strings as primary members of your overlay classes.\u00a0 I&#8217;ve already written about [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-632","post","type-post","status-publish","format-standard","hentry","category-gwt"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=632"}],"version-history":[{"count":7,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/632\/revisions"}],"predecessor-version":[{"id":639,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/632\/revisions\/639"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}