But I stumbled into a problem that I've been unable to solve. When
retrieving a record from the database I use a switch to automatically find
what kind of data was retrieved and add it to an object.
When a java.sql.Date is retrieved and added to this object, calling
JSON.encode will throw the following exception:
org.mozilla.javascript.EcmaError: TypeError: Cannot find function
hasOwnProperty in object 1975-01-01.
That would happen when MooTools try to access the hasOwnProperty method of
the java.sql.Date object. In the following method:
forEach: function(fn, bind){
for (var key in this){
if (this.hasOwnProperty(key)) fn.call(bind, this[key], key, this);
// <- Here
}
},
Has any one had the same problem or knows how I could avoid or correct that?
Thanks.
Vinicius
Another option is to coerce the object yourself via "new Date(<the
returned java date object>)"
[1]:http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/
browse_thread/thread/14b74d5b9ee711fa/1b1e5462e5b2819d
----------------------------------------------------------
Mark Porter
Myna JavaScript Application Server
Easy server-side JS on a Java platform
http://www.mynajs.org
Thanks!
Vinicius Isola
"Não podemos escolher as consequências, mas podemos escolher nossos atos."
On Fri, May 28, 2010 at 11:45 AM, Mark Porter <dm4...@gmail.com> wrote:
> This is probably because Rhino returns Java zative objects by default.
> Changing this to return JS native objects may help[1]
>
> Another option is to coerce the object yourself via "new Date(<the
> returned java date object>)"
>
>
> [1]:http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/
> browse_thread/thread/14b74d5b9ee711fa/1b1e5462e5b2819d<http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/%0Abrowse_thread/thread/14b74d5b9ee711fa/1b1e5462e5b2819d>
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>