Skip to main content

jmaki dojo editor - netbeans 6.0.1

1 reply [Last post]
mom_of_3
Offline
Joined: 2008-03-13

Hi,

I am new to jmaki, javascript and ajax. I recently started using the netbeans IDE and have been trying to get the jmaki dojo editor to work in my php pages without success. In firebug it says that jmaki.listeners. has no properties and points to the editorlistener script. I am using the same code that is listed in the tutorials and that is mentioned here on the message boards but with out any luck. Any help would be wonderful.

From my php page,

<?php
addWidget( array("name" => "dojo.editor",
"value" => "Edit Me", "id" => "myeditor"
));
?>

My Glue.js page

jmaki.debug = true;
// uncomment to show publish/subscribe messages
jmaki.debugGlue = true;

// map topic dojo/fisheye to fisheye handler
jmaki.subscribe("/dojo/fisheye*", function(args) {
jmaki.log("glue.js : fisheye event");
});

// map topics ending with /onSave to the handler
jmaki.subscribe("*onSave", function(args) {
jmaki.log("glue.js : onSave request from: " + args.id + " value=" + args.value);
});

// map topics ending with /onSave to the handler
jmaki.subscribe("*onSelect", function(args) {
jmaki.log("glue.js : onSelect request from: " + args.widgetId);
});

// map topics ending with /onSave to the handler
jmaki.subscribe("*onClick", function(args) {
jmaki.log("glue.js : onClick request from: " + args.widgetId);
});

jmaki.subscribe("/myeditor", "jmaki/listeners/editorListener");

jmaki.listeners.editorListener = function(args) {
var editorId = jmaki.getWidget('myeditor');
var contentValue = editorId.getValue();
if ( typeof contentValue != 'undefined' ) {
jmaki.log("Editor content= " + contentValue);
// send data back to server
jmaki.doAjax({method: 'POST',
url: 'Service.php',
content: {message : contentValue },
callback: function(_req) {
// handle any errors
}
});
} else { // call came from a timer
var editor = jmaki.attributes.get('myeditor');
if ( editor ){
editor.saveState();
}
}
};

jmaki.addTimer( {
action: "call",
timeout: 30000,
target: {
object:"jmaki.listeners",
functionName : "editorListener"
}
});

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
carlavmott
Offline
Joined: 2005-02-10

Hi mom_of_3,

The reason you are getting that is because the listener is listening on '/myeditor' but no one is publishing to that topic. You need to have the following code in

addWidget( array(
"name" => "dojo.editor",
"value" => "Edit This Data",
"id" => "myEditor",
"publish" => "/myeditor"
) );
?>

The id attribute is the id of the widget instance and is not associated with the topic. publish and subscribe attributes affect the topic of the widget. I have an article on the pub/sub mechanism in jMaki that might help. See https://ajax.dev.java.net/introGlue.html Let me know if that is not clear and I will update it.

Carla