PDA

View Full Version : Uncaught TypeError: Cannot call method 'setValue' of undefined



sachintaware
10 May 2012, 11:45 PM
Hello
I have an email app,which uses extjs4 and springmvc.Now on the first attempt everything works fine.
i.e user can log in send mail,but after once the email is sent,if the user clicks on the send email button again,I get the following error in firebug.


Uncaught TypeError: Cannot call method 'setValue' of undefined


at this line.
Ext.getCmp('send-to').setValue(emailAddress);

I have used the ext.onready method for invoking the app.Also,I have the ext-all.js.Then why is the error occuring.
Here is the entire js code for the error.


var emailbtn = new Ext.Button({
text :'Send Email',
scale :'medium',
enableToggle:true,
renderTo:'buttonMail',
handler : function(){

var emailAddress = new Array();
var candidateName = new Array();
for(var i=0; i< store_company.getCount(); i++)
{
emailAddress.push(store_company.getAt(i).get('email'));
candidateName.push(store_company.getAt(i).get('firstName'));

// console.log(emailAddress);
// console.log(candidateName);

Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
Ext.getCmp('send-email-window').show();
}
}

});


send-to is the id of the field declared in the form.

What can I do to resolve the issue??

Thanks

redraid
11 May 2012, 4:02 AM
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.window.Window-cfg-closeAction
(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.window.Window-cfg-closeAction)By default window destroys after close, set values after window show:


Ext.getCmp('send-email-window').show(null, function () {
Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
});

or


var win = Ext.getCmp('send-email-window');
win.on('render', function () {
Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
}, this, {single: true});
win.show();

redraid
11 May 2012, 4:06 AM
Using global ID bad - use itemId -


// window items
items: [
...
{itemId: 'myField', ....}
...
]

// Query item
myField = win.down('#myField');

sachintaware
11 May 2012, 4:24 AM
Thank you redraid
I should have thought about that.
Can you just help me once again.I have a thread opened here regarding browser redirection issue.

http://www.sencha.com/forum/showthread.php?203581-Redirection-for-Login-Page

Please have a look and give your comments.I am able to login first attempt,but after logging out,I am not able to log in again.

Thanks