On Wed, Dec 30, 2009 at 1:34 PM, Daryl Stultz <[email protected]> wrote:
>
> domain.getChildren().add(new DomainEntity()); // fails because new object
is really a WrapperEntity (ok, it doesn't actually crash but it does add a
WrapperEntity to a List of <DomainEntity>.

I'm currently experimenting with WrapFactory and
substituting NativeJavaObjectExt for NativeJavaObject and overriding unwrap:

public class NativeJavaObjectExt extends NativeJavaObject {

// constructors...


public Object unwrap() {

Object wrapped = super.unwrap();
if (wrapped == null) return wrapped;
if (wrapped instanceof Wrapper) wrapped = ((Wrapper) wrapped).unwrap();
return wrapped;

}

}

So the idea is to go from NativeJavaObject (Scriptable) -> DomainEntity
skipping the wrapper. This leads to this error when domain.getChildren() is
called.

org.mozilla.javascript.EvaluatorException: Java method "getChildren" was
invoked with wrapperent...@df1651 as "this" value that can not be converted
to Java type WrapperEntity. (<test>#38)

Hmm, can't be converted to same type?

--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to