From 65e2d6eb01381a86c560806f519c51184e9954a8 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Mon, 22 Dec 2014 12:16:52 +0100 Subject: [PATCH] Fix Json Builder. When creating a new object in the getter it should be added to the parent json. --- .../google/gwt/query/client/builders/JsonBuilderBase.java | 6 ++++-- .../com/google/gwt/query/rebind/JsonBuilderGenerator.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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)) { -- 2.39.5