]> source.dussan.org Git - gwtquery.git/commitdiff
Fix Json Builder.
authorManolo Carrasco <manolo@apache.org>
Mon, 22 Dec 2014 11:16:52 +0000 (12:16 +0100)
committerManolo Carrasco <manolo@apache.org>
Mon, 22 Dec 2014 20:52:23 +0000 (21:52 +0100)
 When creating a new object in the getter it should be added
 to the parent json.

gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java
gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java

index 8ccc9e751bc7d1add98a1801cee88f12ae272ce2..c09836a578a8720595ae148c22987e4a0f08bd53 100644 (file)
@@ -84,8 +84,10 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J
   }
 
   protected Properties getPropertiesBase(String n) {
-    Properties r = p.getJavaScriptObject(n);
-    return r != null ? r : Properties.create();
+    if (p.getJavaScriptObject(n) == null) {
+      p.set(n, Properties.create());
+    }
+    return p.getJavaScriptObject(n);
   }
 
   public String toString() {
index f85177dea8c0050628cf414bd162a5d0f3b6b11d..c2383c19d0c1f6863af1ea43da50875986e18f3d 100644 (file)
@@ -184,10 +184,10 @@ public class JsonBuilderGenerator extends Generator {
       } else if (isTypeAssignableTo(method.getReturnType(), jsonBuilderType)) {
         String q = method.getReturnType().getQualifiedSourceName();
         sw.println("return " + "((" + q + ")GWT.create(" + q + ".class))"
-            + ".load(p.getJavaScriptObject(\"" + name + "\"));");
+            + ".load(getPropertiesBase(\"" + name + "\"));");
       } else if (isTypeAssignableTo(method.getReturnType(), settingsType)) {
         String q = method.getReturnType().getQualifiedSourceName();
-        sw.println("return " + "((" + q + ")p.getJavaScriptObject(\"" + name + "\"));");
+        sw.println("return " + "((" + q + ")getPropertiesBase(\"" + name + "\"));");
       } else if (retType.equals(Properties.class.getName())) {
         sw.println("return getPropertiesBase(\"" + name + "\");");
       } else if (isTypeAssignableTo(method.getReturnType(), jsType)) {