cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia Conforto <tobia.confo...@linux.it>
Subject Re: Java strings vs. Javascript strings
Date Tue, 28 Aug 2007 14:25:25 GMT
Jason Johnston wrote:
> So digging around in the Rhino API I discovered the WrapFactory
> class[1], which is what Rhino uses to wrap Java objects returned from
> methods so that they can be scripted.  By default it wraps
> java.lang.String objects just like it wraps any other Java object,
> giving your script access to its Java methods.  But it does allow you
> to switch this behavior for "primitive" values (strings, numbers,
> booleans), so that it exposes them as native JavaScript primitives
>
> Packages.org.mozilla.javascript.Context.getCurrentContext().getWrapFactory().setJavaPrimitiveWrap(false);

Thank you!  This is going to be a noticeable time saver for us, by
eliminating lots of small errors.

IMHO dynamic languages such as JavaScript are less expensive to program
in than statically typed ones like Java, at least for small- to
medium-sized projects.  But only if Things Just Work™, and having to
deal with only one class of primitive types is part of it.

I'd like to suggest making it the default in Cocoon.
Should I post an issue to JIRA or a message to the dev mailing list?


Tobia

> [1] http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/WrapFactory.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message