2150 |
mathias |
1 |
<!--
|
|
|
2 |
This file demonstrates how the dojox.wire code can be used to do declarative
|
|
|
3 |
wiring of properties/attributes of some object to the properties/attributes of
|
|
|
4 |
another object. It specifically uses the Child (Composite) wire type to perform
|
|
|
5 |
the mapping.
|
|
|
6 |
|
|
|
7 |
Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
|
|
|
8 |
in order for it to execute.
|
|
|
9 |
-->
|
|
|
10 |
<html>
|
|
|
11 |
<head>
|
|
|
12 |
<title>Sample Composite (Child) Wire usage.</title>
|
|
|
13 |
<style type="text/css">
|
|
|
14 |
@import "../../../../dijit/themes/tundra/tundra.css";
|
|
|
15 |
@import "../../../../dojo/resources/dojo.css";
|
|
|
16 |
@import "../../../../dijit/tests/css/dijitTests.css";
|
|
|
17 |
</style>
|
|
|
18 |
|
|
|
19 |
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
|
|
|
20 |
<script type="text/javascript">
|
|
|
21 |
dojo.require("dojo.parser");
|
|
|
22 |
dojo.require("dojo.data.ItemFileReadStore");
|
|
|
23 |
dojo.require("dojox.wire.ml.Invocation");
|
|
|
24 |
dojo.require("dojox.wire.ml.DataStore");
|
|
|
25 |
dojo.require("dojox.wire.ml.Transfer");
|
|
|
26 |
dojo.require("dojox.wire");
|
|
|
27 |
dojo.require("dojox.wire.demos.WidgetRepeater");
|
|
|
28 |
|
|
|
29 |
dataHolder = {
|
|
|
30 |
request: {onItem: function(item){}},
|
|
|
31 |
result: null
|
|
|
32 |
};
|
|
|
33 |
</script>
|
|
|
34 |
</head>
|
|
|
35 |
<body class="tundra">
|
|
|
36 |
<!--
|
|
|
37 |
On load of the page, invoke the fetch method of the object 'DataStore1',
|
|
|
38 |
get its parameters from the JS object 'sample.request
|
|
|
39 |
-->
|
|
|
40 |
<div dojoType="dojox.wire.ml.Invocation"
|
|
|
41 |
triggerEvent="onLoad"
|
|
|
42 |
object="DataStore1" method="fetch" parameters="dataHolder.request">
|
|
|
43 |
</div>
|
|
|
44 |
|
|
|
45 |
<!--
|
|
|
46 |
The store that is queried in this demo
|
|
|
47 |
-->
|
|
|
48 |
<div dojoType="dojo.data.ItemFileReadStore"
|
|
|
49 |
jsId="DataStore1"
|
|
|
50 |
url="countries.json">
|
|
|
51 |
</div>
|
|
|
52 |
|
|
|
53 |
<!--
|
|
|
54 |
Simple container widget for creating a 'list' of some set of widgets
|
|
|
55 |
As defined by the widget type it contains.
|
|
|
56 |
-->
|
|
|
57 |
<div dojoType="dojox.wire.demos.WidgetRepeater"
|
|
|
58 |
widget="dijit.form.Button" jsId="r1">
|
|
|
59 |
</div>
|
|
|
60 |
|
|
|
61 |
<!--
|
|
|
62 |
On the call of the onItem function of 'sample', trigger a binding/mapping of the
|
|
|
63 |
item's attribute 'name' to the target object property: dataHolder.result.caption
|
|
|
64 |
Then invoke the WidgetRepeater (r1)'s createNew method, using the parameters from
|
|
|
65 |
dataHolder.result.
|
|
|
66 |
-->
|
|
|
67 |
<div dojoType="dojox.wire.ml.Action"
|
|
|
68 |
trigger="dataHolder.request" triggerEvent="onItem">
|
|
|
69 |
<div dojoType="dojox.wire.ml.Transfer"
|
|
|
70 |
source="arguments[0]" sourceStore="DataStore1"
|
|
|
71 |
target="dataHolder.result">
|
|
|
72 |
<div dojoType="dojox.wire.ml.ChildWire" name="label" attribute="name"></div>
|
|
|
73 |
</div>
|
|
|
74 |
<div dojoType="dojox.wire.ml.Invocation" object="r1" method="createNew" parameters='dataHolder.result'></div>
|
|
|
75 |
</div>
|
|
|
76 |
</body>
|
|
|
77 |
</html>
|