r19141: add a reasonable subset of the qooxdoo runtime environment, and example appli...
[Samba/ekacnet.git] / swat / apps / qooxdoo-examples / test / RPC_2.html
blob44ce5c256bfb56329afd37ee37d8c4826ce54162
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>qooxdoo &raquo; Demo</title>
5 <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
6 <!--[if IE]>
7 <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
8 <![endif]-->
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. -->
13 </head>
14 <body>
15 <script type="text/javascript" src="../../script/layout.js"></script>
17 <div id="demoDescription">
18 <p>Test for RPC functionality.</p>
19 <p>
20 This tests the ability to issue multiple asynchronous RPC calls to the
21 same service/method, and determine from which request we have received a
22 response. We issue multiple 'sleep' calls, for decreasing amounts of
23 time, and ensure that we can associate the resonses from the
24 later-issued requests to the earlier-received responses.
25 </p>
26 </div>
28 <script type="text/javascript">
29 // qx.Settings.setCustomOfClass("qx.io.remote.RemoteExchange", "enableDebug", true);
30 qx.Settings.setCustomOfClass("qx.io.Json", "enableDebug", true);
32 qx.core.Init.getInstance().defineMain(function() {
33 var layout1 = new qx.ui.layout.VerticalBoxLayout();
34 layout1.setTop(40);
35 layout1.setLeft(20);
36 layout1.setSpacing(4);
39 * Sigh. Both IE and Firefox follow (too strictly) RFC2616 and limit
40 * the number of simultaneous asyncronous HTTP requests to 2. We'll
41 * allow testing just 2 simultaneous requests or issuing 6 simultaneous
42 * requests. In the former case, we'll get expected results. In the
43 * latter, we'll see two at a time being processed.
45 * Note that this applies to both XmlHTTPTransport and IframeTransport.
46 * It is an HTTP limitation, not a limitation of a particular method of
47 * issuing a request.
49 var tooMany = new qx.ui.form.CheckBox("Issue more requests than IE's and Firefox's implementations of HTTP will process simultaneously");
50 layout1.add(tooMany);
52 var crossDomain = new qx.ui.form.CheckBox("Cross Domain");
53 layout1.add(crossDomain);
55 layout1.add(new qx.ui.basic.Label("URL:"));
56 var defaultURL = qx.io.remote.Rpc.makeServerURL();
57 if (defaultURL == null) {
58 defaultURL = "/services/";
60 var url = new qx.ui.form.TextField(defaultURL);
61 layout1.add(url);
63 layout1.add(new qx.ui.basic.Label("Service:"));
64 var service = new qx.ui.form.TextField("qooxdoo.test");
65 layout1.add(service);
67 var layout2 = new qx.ui.layout.HorizontalBoxLayout();
68 layout2.setHeight("auto");
69 layout2.setVerticalChildrenAlign("middle");
70 layout2.setSpacing(4);
71 var start = new qx.ui.form.Button("Start Test");
72 layout2.add(start);
73 var abort = new qx.ui.form.Button("Abort");
74 layout2.add(abort);
75 layout1.add(layout2);
77 // ensure there's room in the queue for all of our requests
78 qx.io.remote.RemoteRequestQueue.getInstance().setMaxConcurrentRequests(8);
80 // We'll be setting url and service upon execute; no need to do it now.
81 var rpc = new qx.io.remote.Rpc();
82 rpc.setTimeout(60000);
83 var mycall;
84 var mycalls = [];
86 start.addEventListener("execute", function() {
87 t0 = new Date().getTime();
89 rpc.setCrossDomain(crossDomain.isChecked());
91 rpc.setUrl(url.getValue());
92 rpc.setServiceName(service.getValue());
94 var seqnum;
95 for (i=(tooMany.isChecked() ? 30 : 10); i > 0; i-=5) {
97 * Always issue an asynchronous request! Issuing a synchronous
98 * request can lock up the entire browser until a response is
99 * received. Bad browser developers! Bad!
101 mycall = rpc.callAsync(function(result, ex, seqnum) {
102 mycalls[seqnum] = null;
103 t = new Date().getTime() - t0;
104 if (ex == null) {
105 layout1.warn(t + ": response " + seqnum + ": " + result);
106 } else {
107 layout1.warn(t + ": exception " + seqnum + ": " + ex);
109 }, "sleep", i.toString()); // FIXME: Why is this sent as a string?
111 t = new Date().getTime() - t0;
112 seqnum = mycall.getSequenceNumber();
113 mycalls[seqnum] = mycall;
114 layout1.warn(t + ": request " + seqnum + " = " + i.toString());
118 abort.addEventListener("execute", function() {
119 for (seqnum in mycalls) {
120 if (mycalls[seqnum] !== null) {
121 rpc.abort(mycalls[seqnum]);
122 mycalls[seqnum] = null;
125 mycalls = [];
128 var d = qx.ui.core.ClientDocument.getInstance();
129 d.add(layout1);
131 </script>
132 </body>
133 </html>