Hello,
I've experimented with WrapFactory. I understand how/when a Java object gets
wrapped into a Scriptable object. When I access my domain object I get a
wrapped object. The problem is when I go to set a value of the domain object
with another domain object. The new value will be a wrapped object. It's a
headache but not unmanageable to unwrap the new value. The big problem is
when dealing with collections. Consider this Java:
public class DomainEntity {
private DomainEntity parent;
private List<DomainEntity> children;
...getters/setters for parent and children
}
public class WrapperEntity {
private DomainEntity delegate;
// getter/setter for delegate
public void setParent(WrapperEntity wrappedParent) {
delegate.setParent(wrappedParent.getDelegate()); // bearable
}
public List<DomainEntity> getChildren() {
return delegate.getChildren();
}
}
and this JavaScript:
var domain = new DomainEntity(); // wrapped to WrapperEntity
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>.
Is there any way to automatically unwrap the object being added to the
collection? Do I need to wrap all collections and implement add(), put(),
etc. in order to unwrap it as it's being added?
Has anyone run into this?
--
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