Skip to main content

Reload widjets

2 replies [Last post]
Joined: 2008-02-18

It's possible to reload a widjet in a page with a timer without reloading the page?
I have to reload a widjet each 5 seconds.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-02-18

if I have a dojo.table what I have to modify in the code?
i have to write /jmaki/table instead of /jmaki/editor?

Joined: 2005-02-10

Hi Cronico,

Yes you can. jMaki has timers built in so it will be pretty easy to do this. See the sample called getwidgetdata for details but I have included some of the code below. In that sample I save the contents of the editor wigdet every couple of minutes automatically. The timer code is added to the glue.js file and will run when the file is loaded. In the timer you specify a function to call and how long to wait before calling that function again. Note that in the this case I check if the value returned from jmaki.getWidget is undefined because the glue.js file loads first and so widgets may not be initialized when the timeout interval expires.

Sorry I don't have time to rewrite this code as I have several presentations next week but I wanted to respond so you can get farther along. Assuming this function is only called by the timer, check if the widget exists and then do a jmaki.doAjax call to get your data. publish your data to the topic the table is listening to so the contents will be updated. I have a blog on how to update data in a table using pub/sub. See

in glue.js:
jmaki.subscribe("/jmaki/editor/onSave", "jmaki.listeners.editorListener");

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

jmaki.addTimer( {
action: "call",
timeout: 30000,
target: {
functionName : "editorListener"