From b1c4d9c1d461e1f14498b81fd4c69a45dbddf8da Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 2 Jun 2010 18:10:07 +0200 Subject: [web-gui] update hello-world Signed-off-by: Michael Olbrich --- .../source/class/hello_world/Application.js | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'web-gui') diff --git a/web-gui/hello-world/source/class/hello_world/Application.js b/web-gui/hello-world/source/class/hello_world/Application.js index 0834bce..1a7e450 100644 --- a/web-gui/hello-world/source/class/hello_world/Application.js +++ b/web-gui/hello-world/source/class/hello_world/Application.js @@ -60,44 +60,54 @@ qx.Class.define("hello_world.Application", // Document is the application root var doc = this.getRoot(); + var core = new qx.ui.container.Composite(new qx.ui.layout.Grid()); + doc.add(core, {left: 50, top: 50}); + core.getLayout().setSpacing(10); + core.getLayout().setColumnAlign(0, "left", "middle"); + + core.add( new qx.ui.basic.Label("RPC Hello World:"), {row: 0, column: 0}); var helloLabel = new qx.ui.basic.Label(""); - doc.add(helloLabel, {left: 100, top: 50}); + core.add(helloLabel, {row: 0, column: 1}); + core.add( new qx.ui.basic.Label("Send Text:"), {row: 1, column: 0}); var echoEdit = new qx.ui.form.TextField(); - doc.add(echoEdit, {left: 100, top: 100}); echoEdit.setWidth(200); + core.add(echoEdit, {row: 1, column: 1}); var echoButton = new qx.ui.form.Button("Echo"); - doc.add(echoButton, {left: 320, top: 100}); + core.add(echoButton, {row: 1, column: 2}); + core.add( new qx.ui.basic.Label("RPC Echo Receive:"), {row: 2, column: 0}); var echoLabel = new qx.ui.basic.Label(""); - doc.add(echoLabel, {left: 500, top: 100}); + core.add(echoLabel, {row: 2, column: 1}); var rpc = new qx.io.remote.Rpc("http://localhost:8080/rpc", "com.pengutronix.jdb.Hello|/"); - rpc.callAsync(function(result, error) { - if (error == null) { - helloLabel.setValue(result); - } - else { - helloLabel.setValue("Error: " + error); - } - }, "com.pengutronix.jdb.Hello.HelloWorld"); + // synchronous RPC call. callSync() throws an exception on error + try { + var val = rpc.callSync("com.pengutronix.jdb.Hello.HelloWorld"); + helloLabel.setValue(val); + } + catch (error) { + helloLabel.setValue("Error: " + error); + } // Add an event listener echoButton.addListener("execute", function(e) { var text = echoEdit.getValue(); if (text == null) text = ""; - rpc.callAsync(function(result, error) { + var handler = function(result, error) { if (error == null) { echoLabel.setValue(result); } else { echoLabel.setValue("Error: " + error); } - }, "com.pengutronix.jdb.Hello.Echo", "s", text); - }); + } + // asynchronous RPC call. The handler will be called with result or error == null + rpc.callAsync(handler, "com.pengutronix.jdb.Hello.Echo", "s", text); + }); } } }); -- cgit v1.2.3