3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
4 <title>qooxdoo
» Demo
</title>
5 <link type=
"text/css" rel=
"stylesheet" href=
"../../resource/css/layout.css"/>
7 <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
9 <script type=
"text/javascript" src=
"../../script/qx.js"></script>
10 <script type=
"text/javascript" src=
".qxrpc"></script>
11 <!-- With the above script, the service URL for a J2EE application can be
12 automatically determined, no matter on what path it's deployed. -->
15 <script type=
"text/javascript" src=
"../../script/layout.js"></script>
17 <div id=
"demoDescription">
18 <p>Test for RPC functionality.
</p>
20 This test calls a whole set of functions to test each of the primitive
21 data types. The comparison results should all end with
": true", and
22 the last test generates an Application Error (#
1000). No other test
23 generates that error, so receiving it means the complete set of tests
27 These functions all use the synchronous interface. You should not use
28 the synchronous interface because with some browsers, the entire browser
29 environment locks up during a synchronous call. If the server hangs for
30 a minute or two, so will the browser! You have been warned.
34 <script type=
"text/javascript">
35 // qx.Settings.setCustomOfClass("qx.io.remote.RemoteExchange", "enableDebug", true);
36 qx
.Settings
.setCustomOfClass("qx.io.Json", "enableDebug", true);
38 qx
.core
.Init
.getInstance().defineMain(function() { var layout1
= new
39 qx
.ui
.layout
.VerticalBoxLayout(); layout1
.setTop(40); layout1
.setLeft(20);
40 layout1
.setSpacing(4);
42 layout1
.add(new qx
.ui
.basic
.Label("URL:"));
43 var defaultURL
= qx
.io
.remote
.Rpc
.makeServerURL();
44 if (defaultURL
== null) {
45 defaultURL
= "/services/";
47 var url
= new qx
.ui
.form
.TextField(defaultURL
);
50 layout1
.add(new qx
.ui
.basic
.Label("Service path:"));
51 var service
= new qx
.ui
.form
.TextField("qooxdoo.test");
54 var start
= new qx
.ui
.form
.Button("Start test");
61 start
.addEventListener("execute", function() {
64 var rpc
= new qx
.io
.remote
.Rpc(url
.getValue(), service
.getValue());
65 rpc
.setTimeout(10000);
67 test
= "getCurrentTimestamp";
68 layout1
.warn("Calling '" + test
+ "'");
69 result
= rpc
.callSync(test
);
70 layout1
.warn("result: now=" + result
.now
);
71 layout1
.warn("result: jsonDate=" + result
.json
.toString());
74 layout1
.warn("Calling '" + test
+ "'");
75 var result
= rpc
.callSync(test
);
76 layout1
.warn("result: {" + result
+ "}");
77 layout1
.warn("Returns a number, got " + typeof(result
) + ": " + (typeof(result
) == "number" && isFinite(result
) ? "true" : "false"));
80 layout1
.warn("Calling '" + test
+ "'");
81 result
= rpc
.callSync(test
, 1);
82 layout1
.warn("result: {" + result
+ "}");
83 layout1
.warn("Returns an integer: " + result
);
86 layout1
.warn("Calling '" + test
+ "'");
87 result
= rpc
.callSync(test
);
88 layout1
.warn("result: {" + result
+ "}");
89 layout1
.warn("Returns a string: " + (typeof(result
) == "string"));
92 layout1
.warn("Calling '" + test
+ "'");
93 result
= rpc
.callSync(test
, "Hello World");
94 layout1
.warn("result: {" + result
+ "}");
95 layout1
.warn("Returns a string: " + result
);
98 layout1
.warn("Calling '" + test
+ "'");
99 var result
= rpc
.callSync(test
);
100 layout1
.warn("result: {" + result
+ "}");
101 layout1
.warn("Returns null: " + (typeof(result
) == "object" && result
=== null ? "true" : "false"));
104 layout1
.warn("Calling '" + test
+ "'");
105 result
= rpc
.callSync(test
, null);
106 layout1
.warn("result: {" + result
+ "}");
107 layout1
.warn("Returns null: " + result
);
109 test
= "getArrayInteger";
110 layout1
.warn("Calling '" + test
+ "'");
111 result
= rpc
.callSync(test
);
112 layout1
.warn("result: {" + result
+ "}");
113 layout1
.warn("Returns an array: " + ((typeof(result
) == "object") && (result
instanceof Array
)));
115 test
= "getArrayString";
116 layout1
.warn("Calling '" + test
+ "'");
117 result
= rpc
.callSync(test
);
118 layout1
.warn("result: {" + result
+ "}");
119 layout1
.warn("Returns an array: " + ((typeof(result
) == "object") && (result
instanceof Array
)));
121 var dataArray
= new Array(5);
129 layout1
.warn("Calling '" + test
+ "'");
130 result
= rpc
.callSync(test
, dataArray
);
131 layout1
.warn("result: {" + result
+ "}");
133 dataArray
= new Array(5);
137 dataArray
[i
] = "Element " + i
;
141 layout1
.warn("Calling '" + test
+ "'");
142 result
= rpc
.callSync(test
, dataArray
);
143 layout1
.warn("result: {" + result
+ "}");
146 layout1
.warn("Calling '" + test
+ "'");
147 result
= rpc
.callSync(test
);
148 layout1
.warn("result: {" + result
+ "}");
149 layout1
.warn("Returns a float: " + (typeof(result
) == "number"));
152 layout1
.warn("Calling '" + test
+ "'");
153 result
= rpc
.callSync(test
);
154 layout1
.warn("result: {" + result
+ "}");
155 layout1
.warn("Returns an object: " + (typeof(result
) == "object"));
158 layout1
.warn("Calling '" + test
+ "'");
162 obj
.o
= new Object();
163 obj
.o
.s
= "This is a test.";
164 result
= rpc
.callSync(test
, obj
);
165 layout1
.warn("result: {" + result
.toString() + "}");
166 layout1
.warn("Returns an object: " + result
);
169 layout1
.warn("Calling '" + test
+ "'");
170 result
= rpc
.callSync(test
);
171 layout1
.warn("result: {" + result
.toString() + "}");
172 layout1
.warn("Returns a boolean = true: " + (typeof(result
) == "boolean"));
175 layout1
.warn("Calling '" + test
+ "'");
176 result
= rpc
.callSync(test
);
177 layout1
.warn("result: {" + result
.toString() + "}");
178 layout1
.warn("Returns a boolean = false: " + (typeof(result
) == "boolean"));
181 layout1
.warn("Calling '" + test
+ "'");
182 result
= rpc
.callSync(test
, true);
183 layout1
.warn("result: {" + result
.toString() + "}");
184 layout1
.warn("Returns a boolean: " + result
);
187 layout1
.warn("Calling '" + test
+ "'");
188 result
= rpc
.callSync(test
, false);
189 layout1
.warn("result: {" + result
.toString() + "}");
190 layout1
.warn("Returns a boolean: " + result
);
192 Date
.prototype.classname
= "Date";
193 var date
= new Date();
195 layout1
.warn("Calling '" + test
+ "'");
196 result
= rpc
.callSync(test
, date
);
197 layout1
.warn("result: {" + result
+ "}");
198 layout1
.warn("Returns a date object, got " + (result
.classname
== date
.classname
));
199 layout1
.warn("Returns matching time " + date
.getTime() + " = " + result
.getTime() + " :" + (result
.getTime() == date
.getTime()));
201 dataArray
= new Array();
203 dataArray
[1] = false;
206 dataArray
[4] = "Hello World";
207 dataArray
[5] = new Array(5);
208 dataArray
[6] = new Object();
209 dataArray
[7] = new Date();
212 layout1
.warn("Calling '" + test
+ "'");
213 result
= rpc
.callSync(test
, dataArray
[0], dataArray
[1], dataArray
[2], dataArray
[3], dataArray
[4], dataArray
[5], dataArray
[6], dataArray
[7]);
214 layout1
.warn("result: {" + result
+ "}");
216 for (i
=0; i
< dataArray
.length
; i
++)
218 layout1
.warn("Returned parameter (" + i
+ ") value '" + result
[i
] + "' matches '" + dataArray
[i
] + "': " + (result
[i
].toString() == dataArray
[i
].toString()));
219 layout1
.warn("Returned parameter (" + i
+ ") type '" + typeof(result
[i
]) + "' matches '" + typeof(dataArray
[i
]) + "': " + (typeof(result
[i
]) == typeof(dataArray
[i
])));
223 layout1
.warn("Calling '" + test
+ "'");
224 result
= rpc
.callSync(test
);
225 // should never get here; we should receive an exception
226 layout1
.warn("ERROR: Should have received an exception! Got: " + result
);
231 alert("Exception on test " + test
+ ": " + ex
);
235 var d
= qx
.ui
.core
.ClientDocument
.getInstance();