PDA

View Full Version : TaskRunner + FormPanel



maquejp
7 Dec 2009, 1:07 AM
Hi,

I dynamically create my formpanel with my server side language (CFM with CFC); It works well except for my TaskRunner... When it is initiate it sent an empy form BUT I do the form.load just before... after this when it runs, it sent the filled form (as it appears on the screen)
I use a global Task runner

In my index.cfm


var tr_automated_save = new Ext.util.TaskRunner();

in my cfc


<!---RENDER--->
#arguments.in_formname#.render('#arguments.in_formcontainer#');
<!---LOADING--->
#arguments.in_formname#.getForm().load({
url : '#arguments.in_urlactionget#',method : 'GET',waitMsg : 'Loading',
success : function(form, action) {},
failure : function(form, action) {
if (action) {
fp_datafailed = Ext.util.JSON.decode(action.response.responseText);
fn_show_error('Form Validation Error(s)', inerrormsg1+ fp_datafailed.errors.reason);
}
else {
fn_show_error('Form Validation Error(s)', inerrormsg2);
}
}
});
<!---AUTOSAVING START--->
tr_automated_save.stopAll();
tr_automated_save.start({
run : function() {
var sb = Ext.getCmp('#arguments.in_formname#_sb');
sb.setText('Saving...');
Ext.getCmp('#arguments.in_formname#').getForm().submit({
method:'POST',
url:'#arguments.in_urlactionset#0&v_useralias='+loc_useralias,
clientValidation : false,
success : function () {
sb.setText('(Saved at ' + new Date().format('d m Y H:i:s') + ')');
},
failure : function (form, action) {
if (action.response) {
fp_datafailed = Ext.util.JSON.decode(action.response.responseText);
if (fp_datafailed) {
if (fp_datafailed.errors.code == 1) {
fn_show_error('System Error',fp_datafailed.errors.reason);
}
if (fp_datafailed.errors.code == 2) {
hideshowpanelform('p_datalocked');
tr_saveform.stopAll();
}
} else {
fn_show_error('Validation Error','Please check all mandatory fields! (bordered in red)');
}
} else {
fn_show_error('Validation Error','Please check all mandatory fields! (bordered in red)');
}
sb.setText('Not saved validation error');
}
})
},
interval : loc_autosaveminu * 60 * 1000
});


Any idea how solve this ... A way to avoid the first launch?

maquejp
7 Dec 2009, 1:33 AM
Ok for the moment, I use a "flag" to avoid the first start

in my index.cfm

var tr_automated_save_first;
in my cfc


tr_automated_save_first = 1;
tr_automated_save.start({
run : function() {
if (tr_automated_save_first != 1) {
...
}
else
{tr_automated_save_first=0}


Maybe I should put the taskrunner start in the load success...