Author: shane.bryzak(a)jboss.com
Date: 2010-01-03 09:44:48 -0500 (Sun, 03 Jan 2010)
New Revision: 11903
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
uninitialized collections should be undefined
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java
===================================================================
---
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java 2010-01-03
13:52:56 UTC (rev 11902)
+++
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java 2010-01-03
14:44:48 UTC (rev 11903)
@@ -36,6 +36,8 @@
private static final byte[] ELEMENT_TAG_OPEN =
"<element>".getBytes();
private static final byte[] ELEMENT_TAG_CLOSE =
"</element>".getBytes();
+ private static final byte[] UNDEFINED_TAG =
"<undefined/>".getBytes();
+
private boolean loadLazy = false;
public void setLoadLazy(boolean loadLazy)
@@ -46,18 +48,18 @@
@SuppressWarnings("unchecked")
public void marshal(OutputStream out) throws IOException
{
- out.write(BAG_TAG_OPEN);
-
// Fix to prevent uninitialized lazy loading in Hibernate
if (value instanceof PersistentCollection && !loadLazy)
{
if (!((PersistentCollection) value).wasInitialized())
{
- out.write(BAG_TAG_CLOSE);
+ out.write(UNDEFINED_TAG);
return;
}
}
+ out.write(BAG_TAG_OPEN);
+
Collection<Object> vals = null;
// If the value is an array, convert it to a Collection
Modified: modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
===================================================================
--- modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2010-01-03
13:52:56 UTC (rev 11902)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2010-01-03
14:44:48 UTC (rev 11903)
@@ -699,6 +699,7 @@
}
return m;
case "date": return Seam.deserializeDate(element.firstChild.nodeValue);
+ case "undefined": return undefined;
default: return null;
}
}
@@ -809,7 +810,6 @@
this.refs = new Seam.Map();
Seam.Delta.prototype.testEqual = function(v1, v2) {
- var eq = this.testEqual;
if (v1 == null) return v2 == null;
switch (typeof(v1)) {
case "number":
@@ -827,7 +827,7 @@
if (!(v2 instanceof Array)) return false;
if (v1.length != v2.length) return false;
for (var i=0; i<v1.length; i++) {
- if (!eq(v1[i], v2[i])) return false;
+ if (!this.testEqual(v1[i], v2[i])) return false;
}
return true;
} else if (v1 instanceof Seam.Map) {
@@ -835,8 +835,8 @@
if (v1.size() != v2.size()) return false;
for (var i=0; i<v1.size(); i++) {
var e = v1.elements[i];
- if (Seam.getBeanType(e.key) && eq(e.value,
v2.get(this.getSourceObject(e.key)))) break;
- if (eq(e.value, v2.get(e.key)) && (e.value != null ||
v2.contains(e.key))) break;
+ if (Seam.getBeanType(e.key) && this.testEqual(e.value,
v2.get(this.getSourceObject(e.key)))) break;
+ if (this.testEqual(e.value, v2.get(e.key)) && (e.value != null ||
v2.contains(e.key))) break;
return false;
}
return true;
@@ -1100,6 +1100,7 @@
}
Seam.Model.prototype.expand = function(v, p, callback) {
+ if (v[p] != undefined) return;
var refId = this.getRefId(v);
var r = this.createExpandRequest(refId, p);
var env = Seam.createEnvelope(Seam.createHeader(r.id), r.data);
@@ -1117,11 +1118,11 @@
Seam.Model.prototype.processExpandResponse = function(modelNode, refId, propName) {
var refsNode = Seam.Xml.childNode(modelNode, "refs");
- var valueNode = Seam.Xml.childNode(modelNode, "value");
+ var resultNode = Seam.Xml.childNode(modelNode, "result");
Seam.unmarshalRefs(refsNode, this.sourceRefs);
Seam.unmarshalRefs(refsNode, this.workingRefs);
- this.sourceRefs[refId][propName] =
Seam.unmarshalValue(valueNode.firstChild,this.sourceRefs);
- this.workingRefs[refId][propName] =
Seam.unmarshalValue(valueNode.firstChild,this.workingRefs);
+ this.sourceRefs[refId][propName] =
Seam.unmarshalValue(resultNode.firstChild,this.sourceRefs);
+ this.workingRefs[refId][propName] =
Seam.unmarshalValue(resultNode.firstChild,this.workingRefs);
if (this.callback) this.callback(this);
}
}
\ No newline at end of file
Show replies by date