Welcome, guest ( Login )

WikiHome » DojoDataUseCases » Binding Widget to TopicPublishAction

Binding Widget to TopicPublishAction

Version 9, changed by jaredj 02/20/2007.   Show version history

Summary:  

This use-case demonstrates how a widget/action on a widget can invoke a publish to a specific topic.  The main purpose of this is to demonstrate how widgets could be declaratively wired together through topics and markup.   The programmatic side would simply do something like connecting to an event on a widget, which then triggers a call to dojo.event.topic.publish() or the like.

Scenario:

A user enters some test and exits the textbox.  On exiting of the textbox the value is published to a topic.  

Declarative:

// Do not necessarily need a programmatic example; it can be implemented using the standard dojo.event.topic mechanisms. 

...
<!-- Publishes the contents of textBox 'Test1' on exit of the textbox to a topic -->
<input type="text" id="Text1" />

<div dojoType="ibm:Action" widgetId="Action1"
    trigger="Text1"
    triggerEvent="onblur"
    topic="textbox1Changed"
    params="Text1.value"></div>
...




Test Cases

Declarative:

<html>
<head>
<title>Test Binding</title>
<script>
var djConfig = {isDebug: true};
</script>
<script src="../../../../dojo/dojo.js"></script>
<script>
dojo.registerModulePath("dojox.data", "../dojox/src/data");
dojo.require("dojox.data.decl.Action");
dojo.require("dojox.data.decl.Binding");
</script>
</head>
<body>
<!-- View -->
<input type="text" id="Text1" />
<input type="text" id="Text2" />

<div dojoType="ibm:Action" widgetId="Action1"
    trigger="Text1"
    triggerEvent="onblur"
    topic="textbox1Changed"
    params="Text1"></div>

<div dojoType="ibm:Binding" widgetId="Binding1"
    triggerTopic="textbox1Changed"
    source="arguments[0]"
    target="Text2.value"></div>
</body>
</html>


Discussion:







Attachments (0)

  File By Size Attached Ver.