2150 |
mathias |
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" djConfig="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"></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>
|
|
|
79 |
|
|
|
80 |
<!--
|
|
|
81 |
Whenever a key is entered into the textbox, copy the value somewhere, then invoke a method on another widget, in this case
|
|
|
82 |
on just another text box.
|
|
|
83 |
-->
|
|
|
84 |
<div dojoType="dojox.wire.ml.Action"
|
|
|
85 |
id="action1"
|
|
|
86 |
trigger="inputField"
|
|
|
87 |
triggerEvent="onkeyup">
|
|
|
88 |
<div dojoType="dojox.wire.ml.Invocation" object="inputField" method="getValue" result="data.tempData"></div>
|
|
|
89 |
<div dojoType="dojox.wire.ml.Invocation" id="targetCopy" object="targetField1" method="setValue" parameters="data.tempData"></div>
|
|
|
90 |
</div>
|
|
|
91 |
|
|
|
92 |
<!--
|
|
|
93 |
Whenever the primary cloning invocation completes, invoke a secondary cloning action.
|
|
|
94 |
-->
|
|
|
95 |
<div dojoType="dojox.wire.ml.Action"
|
|
|
96 |
id="action2"
|
|
|
97 |
trigger="targetCopy"
|
|
|
98 |
triggerEvent="onComplete">
|
|
|
99 |
<!--
|
|
|
100 |
Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
|
|
|
101 |
code supports both getX and setX functions of setting a property as well as direct access. It first looks
|
|
|
102 |
for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
|
|
|
103 |
of the standard getValue/setValue API of dijit form widgets, these transfers work really well and are very compact.
|
|
|
104 |
-->
|
|
|
105 |
<div dojoType="dojox.wire.ml.Transfer" source="targetField1.value" target="targetField2.value"></div>
|
|
|
106 |
</div>
|
|
|
107 |
</body>
|
|
|
108 |
</html>
|