From: Manolo Carrasco Date: Mon, 22 Dec 2014 11:16:52 +0000 (+0100) Subject: Fix Json Builder. X-Git-Tag: gwtquery-project-1.4.3~9^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=65e2d6eb01381a86c560806f519c51184e9954a8;p=gwtquery.git Fix Json Builder. When creating a new object in the getter it should be added to the parent json. --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java index 8ccc9e75..c09836a5 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java @@ -84,8 +84,10 @@ public abstract class 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() { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java index f85177de..c2383c19 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java @@ -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)) {