source: Dev/trunk/src/client/dojox/wire/demos/markup/demo_TopicWiring.html

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.6 KB
Line 
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 publish and subscribe
4        to topics.  In this case the setting of a value on one textbox triggers a
5        publish of that value to a topic.  Another invoke is wired to fire when
6        values are published to that topic which is then displayed in another
7        textbox.
8-->
9<html>
10<head>
11        <title>Sample Topic Wiring</title>
12        <style type="text/css">
13
14                @import "../../../../dijit/themes/tundra/tundra.css";
15                @import "../../../../dojo/resources/dojo.css";
16                @import "../../../../dijit/tests/css/dijitTests.css";
17                @import "../TableContainer.css";
18
19                .splitView {
20                        width: 90%;
21                        height: 90%;
22                        border: 1px solid #bfbfbf;
23                        border-collapse: separate;
24                }
25        </style>
26
27        <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script>
28        <script type="text/javascript">
29                dojo.require("dojo.parser");
30                dojo.require("dojox.wire");
31                dojo.require("dojox.wire.ml.Invocation");
32                dojo.require("dojox.wire.ml.DataStore");
33                dojo.require("dojox.wire.ml.Transfer");
34                dojo.require("dojox.wire.ml.Data");
35
36                dojo.require("dijit.form.TextBox");
37        </script>
38</head>
39
40<body class="tundra">
41
42        <!-- Layout -->
43        <font size="3"><b>Demo of Topic Wiring</b></font><br/><br/>
44        This demo shows how you can wire events to publish to a topic as well as receive topic events
45        <br/>
46        <br/>
47        <table>
48                <tr>
49                        <td>
50                                <div dojoType="dijit.form.TextBox" data-dojo-id="inputField" value="" size="50" intermediateChanges="true"></div>
51                        </td>
52                </tr>
53                <tr>
54                        <td>
55                                <div dojoType="dijit.form.TextBox" data-dojo-id="targetField1" value="" disabled="true" size="50"></div>
56                        </td>
57                </tr>
58        </table>
59
60
61        <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
62       
63        <!--
64                Whenever a key is entered into the textbox, publish the value of it to a topic.
65        -->
66        <div dojoType="dojox.wire.ml.Action"
67                id="action1"
68                trigger="inputField"
69                triggerEvent="onChange">
70                <div dojoType="dojox.wire.ml.Invocation" topic="sampleTopic"    parameters="inputField.value"></div>
71        </div>   
72
73        <!--
74                Whenever a value is published to a topic, set it as the value of the textbox by using Transfer to transfer the value from the
75                topic publish to the target property.  The underlying wire code will invoke the proper setter for the target, in this case
76                it will invoke the dijit 'attr' function.
77        -->
78        <div dojoType="dojox.wire.ml.Action"
79                id="action2"
80                triggerTopic="sampleTopic">
81                <div dojoType="dojox.wire.ml.Transfer" target="targetField1.value"  source="arguments[0]"></div>
82        </div>   
83</body>
84</html>
Note: See TracBrowser for help on using the repository browser.