PDA

View Full Version : Form Load



jpalla
9 Aug 2011, 3:16 PM
Hi,
I am try to load a form field. I have the following code:

Ext.onReady(function() {
Ext.QuickTips.init();

var form = new Ext.form.FormPanel({
renderTo: 'docbody',
title : 'Composite Fields',
autoHeight: true,
width : 600,

bodyStyle: 'padding: 5px',
defaults: {
anchor: '0'
},
items : [
{
xtype : 'textfield',
name : 'email',
fieldLabel: 'Email Address',
anchor : '-20'
}
],
buttons: [
{
text : 'Load test data',
handler: function() {
form.form.load({url:'http://localhost:8080/dynatest2/' });

}
}
]
});
});


The url 'http://localhost:8080/dynatest2/' returns a json output as :

{"success":true,"data":{ "email": "[email protected]"}}


However , the form is not loading. Am I doing any mistake here?

Also in the firebug , can anyone tell me where or how to look for the accessed urls(to check the status whether url submission is successful or not ) and the server output?

httpdotcom
9 Aug 2011, 5:37 PM
My first recommendation is to not name an object the same as a major component type (don't call a Ext.form.FormPanel "form")

form.form.load isn't a valid function; form.getForm().load should be the proper call

Add "id='email'" to your form element, and that might be enough to solve your problem.

jpalla
9 Aug 2011, 7:01 PM
Thanks for the response. I made the changes that you suggested. (added id:'email' and getForm()) It did not work. The html page is in the extjs examples folder.(file:///C:/dev/ext-3.4.0/examples/form/composite-field.html ). Is this anything to do with cross domain, as the server url is 'http://localhost:8080/dynatest2' ?

Ext.onReady(function() {
Ext.QuickTips.init();

var formPanel = new Ext.form.FormPanel({
renderTo: 'docbody',
title : 'Composite Fields',
autoHeight: true,
width : 600,

bodyStyle: 'padding: 5px',
defaults: {
anchor: '0'
},
items : [
{
xtype : 'textfield',
name : 'email',
id:'email',
fieldLabel: 'Email Address',
anchor : '-20'
}
],
buttons: [
{
text : 'Load test data',
handler: function() {
formPanel.getForm().load({url:'http://localhost:8080/dynatest2/' });

}
}
]
});
});

jpalla
10 Aug 2011, 4:45 PM
This was resolved.The jsp page(server page) has some text other than json data.When I removed the non json text, it worked!