PDA

View Full Version : Submit Form W/ HttpProxy



rich_montana
16 Jul 2009, 9:16 PM
Hi so i am submitting form inputs to a to a web service using http proxy. To me it seems as if i am not setting up the handler correctly. I saw this because I have the form but the function i have to retrieve the form is being called upon the page load. I verified this by adding an alert. I don't think this function should be called until the form is submitted. This is one problem but am not sure if it is independent or related to the bigger issue of a js error that is preventing the form to load at all. :

"KntAppTabs is not definedchrome://firebug/content/blank.gif KntAppTabs.superclass.initComponent.apply(this, arguments);
KnTOnlin...ppMain.js (line 27)"

Here is the code...


Ext.onReady(function(){

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var bd = Ext.getBody();

bd.createChild({tag: 'h2', html: 'Volunteer Application'});

KntAppTabs = Ext.extend(new Ext.FormPanel({

initComponent: function() {
Ext.apply(this,{
id: 'onlineappForm',
ds: new Ext.data.Store({
storeId: 'onlineAppDS',
method: 'POST',
proxy: new Ext.data.HttpProxy({
url: applicantSubmitURL,
xmlData: getOnlineAppPostXML()
})
}),
labelWidth: 75,
border:false,
width: 650,
items: Ext.form_items.inputs,
});
KntAppTabs.superclass.initComponent.apply(this, arguments);
},

buttons: [
{ text: 'Save',
type: 'submit',
scope: this,
handler: function(){
KntAppTabs.getForm().submit({
success: function(f,a){Ext.Msg.alert('Success','It worked');},
failure: function(f,a){Ext.Msg.alert('Warning',a.result.errormsg);}
});
}
},{text: 'Cancel'}
]
}));
Ext.reg('onlineappForm', KntAppTabs);
KntAppTabs.render(document.body);

});


Any and all help would be greatly appreciated!
--RICH

Stripeman
16 Jul 2009, 11:37 PM
http://www.jslint.com/ is your friend...
ERROR:

items: Ext.form_items.inputs,

I dont know if that is the root of your problem I have yet to do a submit like that. I still have so much to learn...but I have been doing it like this:


dataGrid.on('afteredit', updateDB);

and then (sorry for the long example)


function updateDB (oGrid_event){
var sm = dataGrid.getSelectionModel();
var sel = sm.getSelected();
var selid = sel.id;
var record_id;

if (isInt(selid) != 0) {
record_id = selid;
}else if (isInt(selid) == 0){
record_id = 'new';
}

Ext.Ajax.request(
{
waitMsg : 'Saving changes, please wait...',
method : 'POST',
url :'update.php',
success:function(result, request) {

var returnData = Ext.util.JSON.decode(result.responseText);

if (returnData.success){
Ext.msg.msg('Alert', '<div class="success">Record Saved!</div>');
}else{
Ext.MessageBox.show({
title: 'Update Problem!',
msg: "Query Problem, Please see administrator",
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}

},
failure: function(result, request) {

Ext.MessageBox.show({
title: 'Status change',
msg: "AJAX Service Error, Please see administrator",
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
},
params : {
id : record_id,
field : oGrid_event.field,
value : oGrid_event.value,
'table' : 'dataPositions',
'ac' : 'saveData',
'page' : 'adminPositions'
}
}
)

dataStore.reload();

}


}

rich_montana
20 Jul 2009, 8:19 PM
thank you so much for the reply. and ive been pretty absent for a response so i apologize. here are my 2 questions to your response.

This is not an error:


items: Ext.form_items.inputs
This object is created in another class that is included in the html prior to the js file in question. The js validator would that thats an error because it wouldn't know about the other vars from that include file. I verified this by commenting out that line. The same error:



KntAppTabs is not defined line 28
... still exists.

ALSO ...
I do like the way you have the datastore load upon the click of the submit. A couple questions regarding that is do you have still instantiate (maybe bad terminology) the datastore in the formpanel and then upon that click the store gets created, and httpproxy sends the request?