Debian Codegraph @

dojox/wire/demos/markup/demo_ActionChaining.html

raw symbols SCIP
1 <!--
2 This file demonstrates how the dojox.wire code can be used to do declarative
3 wiring of events. Specifically, it shows how you can chain actions together
4 in a sequence. In this case the setting of a value on one textbox triggers a
5 copy over to another textbox. That in turn triggers yet another copy to another
6 text box.
7 -->
8 <html>
9 <head>
10 <title>Sample Action Chaining</title>
11 <style type="text/css">
12
13 @import "../../../../dijit/themes/tundra/tundra.css";
14 @import "../../../../dojo/resources/dojo.css";
15 @import "../../../../dijit/tests/css/dijitTests.css";
16 @import "../TableContainer.css";
17
18 .splitView {
19 width: 90%;
20 height: 90%;
21 border: 1px solid #bfbfbf;
22 border-collapse: separate;
23 }
24 </style>
25
26 <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script>
27 <script type="text/javascript">
28 dojo.require("dojo.parser");
29 dojo.require("dojox.wire");
30 dojo.require("dojox.wire.ml.Invocation");
31 dojo.require("dojox.wire.ml.DataStore");
32 dojo.require("dojox.wire.ml.Transfer");
33 dojo.require("dojox.wire.ml.Data");
34 dojo.require("dijit.form.TextBox");
35 </script>
36 </head>
37
38 <body class="tundra">
39
40 <!-- Layout -->
41 <font size="3"><b>Demo of Chaining Actions:</b></font><br/><br/>
42 This demo shows how you can chain actions together to fire in a sequence.
43 Such as the completion of setting one value on a widget triggers the setting of another value on the widget
44 <br/>
45 <br/>
46 <table>
47 <tr>
48 <td>
49 <div dojoType="dijit.form.TextBox" id="inputField" value="" size="50" intermediateChanges="true"></div>
50 </td>
51 </tr>
52 <tr>
53 <td>
54 <div dojoType="dijit.form.TextBox" id="targetField1" value="" disabled="true" size="50"></div>
55 </td>
56 </tr>
57 <tr>
58 <td>
59 <div dojoType="dijit.form.TextBox" id="targetField2" value="" disabled="true" size="50"></div>
60 </td>
61 </tr>
62 </table>
63
64
65 <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
66
67 <!--
68 This is an example of using the declarative data value definition.
69 These are effectively declarative variables to act as placeholders
70 for data values.
71 -->
72 <div dojoType="dojox.wire.ml.Data"
73 id="data">
74 <div dojoType="dojox.wire.ml.DataProperty"
75 name="tempData"
76 value="">
77 </div>
78 <div dojoType="dojox.wire.ml.DataProperty"
79 name="value"
80 value="value">
81 </div>
82 </div>
83
84 <!--
85 Whenever a key is entered into the textbox, copy the value somewhere, then invoke a method on another widget, in this case
86 on just another text box.
87 -->
88 <div dojoType="dojox.wire.ml.Action"
89 id="action1"
90 trigger="inputField"
91 triggerEvent="onChange">
92 <div dojoType="dojox.wire.ml.Transfer" source="inputField.value" target="data.tempData"></div>
93 <div dojoType="dojox.wire.ml.Invocation" id="targetCopy" object="targetField1" method="set" parameters="data.value, data.tempData"></div>
94 </div>
95
96 <!--
97 Whenever the primary cloning invocation completes, invoke a secondary cloning action.
98 -->
99 <div dojoType="dojox.wire.ml.Action"
100 id="action2"
101 trigger="targetCopy"
102 triggerEvent="onComplete">
103 <!--
104 Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
105 code supports both getX and setX functions of setting a property as well as direct access. It first looks
106 for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
107 of the standard getValue/setValue API of dijit form widgets, these transfers work really well and are very compact.
108 -->
109 <div dojoType="dojox.wire.ml.Transfer" source="targetField1.value" target="targetField2.value"></div>
110 </div>
111 </body>
112 </html>