1.1 --- a/json/src/main/java/org/apidesign/html/json/impl/JSON.java Thu May 09 17:13:54 2013 +0200
1.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/JSON.java Thu May 09 20:30:25 2013 +0200
1.3 @@ -94,7 +94,11 @@
1.4 Context c, Runnable whenDone, Object[] result,
1.5 String urlBefore, String urlAfter
1.6 ) {
1.7 - JSONCall call = PropertyBindingAccessor.createCall(whenDone, result, urlBefore, urlAfter);
1.8 + loadJSON(c, whenDone, result, urlBefore, urlAfter, null);
1.9 + }
1.10 +
1.11 + public static void loadJSON(Context c, Runnable whenDone, Object[] result, String urlBefore, String urlAfter, String method) {
1.12 + JSONCall call = PropertyBindingAccessor.createCall(whenDone, result, urlBefore, urlAfter, method);
1.13 Transfer t = ContextAccessor.findTransfer(c);
1.14 t.loadJSON(call);
1.15 }
2.1 --- a/json/src/main/java/org/apidesign/html/json/impl/ModelProcessor.java Thu May 09 17:13:54 2013 +0200
2.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/ModelProcessor.java Thu May 09 20:30:25 2013 +0200
2.3 @@ -849,6 +849,9 @@
2.4 } else {
2.5 body.append("null");
2.6 }
2.7 + if (!"GET".equals(onR.method())) {
2.8 + body.append(", \"").append(onR.method()).append('"');
2.9 + }
2.10 body.append(");\n");
2.11 // body.append(" ").append(clazz.getSimpleName()).append(".").append(n).append("(");
2.12 // body.append(wrapParams(e, null, className, "ev", "data"));
3.1 --- a/json/src/main/java/org/apidesign/html/json/impl/PropertyBindingAccessor.java Thu May 09 17:13:54 2013 +0200
3.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/PropertyBindingAccessor.java Thu May 09 20:30:25 2013 +0200
3.3 @@ -43,8 +43,7 @@
3.4 protected abstract <M> PropertyBinding newBinding(PBData<M> d);
3.5 protected abstract <M> FunctionBinding newFunction(FBData<M> d);
3.6 protected abstract JSONCall newCall(
3.7 - Runnable whenDone, Object[] result, String urlBefore, String urlAfter
3.8 - );
3.9 + Runnable whenDone, Object[] result, String urlBefore, String urlAfter, String method);
3.10
3.11
3.12 static <M> PropertyBinding create(PBData<M> d) {
3.13 @@ -54,9 +53,8 @@
3.14 return DEFAULT.newFunction(d);
3.15 }
3.16 static JSONCall createCall(
3.17 - Runnable whenDone, Object[] result, String urlBefore, String urlAfter
3.18 - ) {
3.19 - return DEFAULT.newCall(whenDone, result, urlBefore, urlAfter);
3.20 + Runnable whenDone, Object[] result, String urlBefore, String urlAfter, String method) {
3.21 + return DEFAULT.newCall(whenDone, result, urlBefore, urlAfter, method);
3.22 }
3.23
3.24 public static final class PBData<M> {
4.1 --- a/json/src/main/java/org/apidesign/html/json/spi/JSONCall.java Thu May 09 17:13:54 2013 +0200
4.2 +++ b/json/src/main/java/org/apidesign/html/json/spi/JSONCall.java Thu May 09 20:30:25 2013 +0200
4.3 @@ -31,12 +31,18 @@
4.4 private final Object[] result;
4.5 private final String urlBefore;
4.6 private final String urlAfter;
4.7 + private final String method;
4.8
4.9 - JSONCall(Runnable whenDone, Object[] result, String urlBefore, String urlAfter) {
4.10 + JSONCall(Runnable whenDone, Object[] result, String urlBefore, String urlAfter, String method) {
4.11 this.whenDone = whenDone;
4.12 this.result = result;
4.13 this.urlBefore = urlBefore;
4.14 this.urlAfter = urlAfter;
4.15 + this.method = method;
4.16 + }
4.17 +
4.18 + public String getMethod() {
4.19 + return method;
4.20 }
4.21
4.22 public boolean isJSONP() {
5.1 --- a/json/src/main/java/org/apidesign/html/json/spi/PropertyBinding.java Thu May 09 17:13:54 2013 +0200
5.2 +++ b/json/src/main/java/org/apidesign/html/json/spi/PropertyBinding.java Thu May 09 20:30:25 2013 +0200
5.3 @@ -49,8 +49,8 @@
5.4 }
5.5
5.6 @Override
5.7 - protected JSONCall newCall(Runnable whenDone, Object[] result, String urlBefore, String urlAfter) {
5.8 - return new JSONCall(whenDone, result, urlBefore, urlAfter);
5.9 + protected JSONCall newCall(Runnable whenDone, Object[] result, String urlBefore, String urlAfter, String method) {
5.10 + return new JSONCall(whenDone, result, urlBefore, urlAfter, method);
5.11 }
5.12 };
5.13 }
6.1 --- a/ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java Thu May 09 17:13:54 2013 +0200
6.2 +++ b/ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java Thu May 09 20:30:25 2013 +0200
6.3 @@ -25,8 +25,10 @@
6.4 import java.io.InputStreamReader;
6.5 import java.io.PushbackInputStream;
6.6 import java.io.Reader;
6.7 +import java.net.HttpURLConnection;
6.8 import java.net.MalformedURLException;
6.9 import java.net.URL;
6.10 +import java.net.URLConnection;
6.11 import java.util.Iterator;
6.12 import java.util.concurrent.Executor;
6.13 import java.util.concurrent.Executors;
6.14 @@ -92,7 +94,16 @@
6.15 }
6.16 try {
6.17 final URL u = new URL(base, url.replace(" ", "%20"));
6.18 - final PushbackInputStream is = new PushbackInputStream(u.openStream(), 1);
6.19 + URLConnection conn = u.openConnection();
6.20 + if (conn instanceof HttpURLConnection) {
6.21 + HttpURLConnection huc = (HttpURLConnection) conn;
6.22 + if (call.getMethod() != null) {
6.23 + huc.setRequestMethod(call.getMethod());
6.24 + }
6.25 + }
6.26 + final PushbackInputStream is = new PushbackInputStream(
6.27 + conn.getInputStream(), 1
6.28 + );
6.29 boolean array = false;
6.30 boolean string = false;
6.31 if (call.isJSONP()) {