Hi,
I was trying to implement the example provided by Martin Ankerl at http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/
Following is my code:
------------------------------------------------------------------------------------------
<head>
<style type="text/css">
@import "../js/dojo-release-1.0.1/dijit/themes/tundra/tundra.css";
@import "../js/dojo-release-1.0.1/dojoroot/dojo/resources/dojo.css"
</style>
<script type="text/javascript" src="../js/dojo-release-1.0.1/dojo/dojo.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojox.cometd");
dojox.cometd.init("../cometd");
dojox.cometd.subscribe('/hello/world', false, "publishHandler");
publishHandler = function(msg) {
alert("hi");
}
</script>
</head>
<body>
<input type="button"
onclick="dojox.cometd.publish('/hello/world', { test: 'hello world' } )"
value="Click Me!">
</body>
<style type="text/css">
@import "../js/dojo-release-1.0.1/dijit/themes/tundra/tundra.css";
@import "../js/dojo-release-1.0.1/dojoroot/dojo/resources/dojo.css"
</style>
<script type="text/javascript" src="../js/dojo-release-1.0.1/dojo/dojo.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojox.cometd");
dojox.cometd.init("../cometd");
dojox.cometd.subscribe('/hello/world', false, "publishHandler");
publishHandler = function(msg) {
alert("hi");
}
</script>
</head>
<body>
<input type="button"
onclick="dojox.cometd.publish('/hello/world', { test: 'hello world' } )"
value="Click Me!">
</body>
------------------------------------------------------------------------------------------
cometd in web.xml:
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.mortbay.cometd.continuation.ContinuationCometdServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<servlet-name>cometd</servlet-name>
<servlet-class>org.mortbay.cometd.continuation.ContinuationCometdServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
It is a fairly simple example but I'm a novice. When I launch the url in the browser, the page is shown with no javascript errors. I click on button and nothing happens.
Firebug shows POST http://localhost:8989/appl/cometd with the response 'loading' for like ever.
Any help would be appreciated.
thanks!
RalfP

the dojox.cometd.init() call
the dojox.cometd.init() call wants a url. Assuming your cometd server is running on port 8989, the call would look like:
dojox.cometd.init("http://localhost:8989/cometd");
also, in the subscription, I am not sure the false is valid. i've only used dojox.cometd.subscribe like:
dojox.cometd.subscribe("/hello/world",function(msg){ alert(msg.data); });hope this helps.