|
Replies:
2
-
Last Post:
Mar 1, 2008 12:00 PM
by: cronico
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
Reload widjets
Posted:
Feb 27, 2008 9:21 AM
|
|
|
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. Thanks
|
|
|
|
|
|
|
Re: Reload widjets
Posted:
Feb 28, 2008 3:39 PM
in response to: cronico
|
|
|
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 http://weblogs.java.net/blog/carlavmott/archive/2007/09/how_to_implemen.html
in glue.js: jmaki.subscribe("/jmaki/editor/onSave", "jmaki.listeners.editorListener");
jmaki.listeners.editorListener = function(args) { var contentValue = args.value; var contentId = args.id; 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 ){ editor.saveState(); } } };
jmaki.addTimer( { action: "call", timeout: 30000, target: { object:"jmaki.listeners", functionName : "editorListener" } });
|
|
|
|
|
|
|
|
Re: Reload widjets
Posted:
Mar 1, 2008 12:00 PM
in response to: cronico
|
|
|
if I have a dojo.table what I have to modify in the code? i have to write /jmaki/table instead of /jmaki/editor?
|
|
|
|
|