PDA

View Full Version : Two errors after moving from 3.0 to 3.1



leonid1
22 Jan 2010, 4:21 AM
After moving from 3.0 to 3.1 randomly , but very often two errors arises in our application. One of them is


Line: 1793
Error: 'Ext.elCache[...].events' is null or not an object

It arises either in Ext.EventManager.addListener method

function addListener(el, ename, fn, wrap, scope){
el = Ext.getDom(el);
var id = getId(el), es = Ext.elCache[id].events, wfn;
...

or in Ext.EventManager.removeListener method

removeListener : function(el, eventName, fn, scope){
el = Ext.getDom(el);
var id = getId(el), f = el && (Ext.elCache[id].events)[eventName] || [],
wrap, i, l, k, wf;
...

I can check id and it is not presented in Ext.elCache. At the same time both Ext.getCmd(id) and Ext.get(id) return objects (in addListener only Ext.get(id) returns while Ext.getCmd(id) is undefined). This error first occurs when I try to open or close a window, but then it may occur at any place.

Second error may arise when we try to open or close combobox in a grid. Here is it

Line: 1874
Error: 'fn.task' is null or not an object

It arises in Ext.EventManager.createBuffered method

function createBuffered(h, o, fn){
fn.task = new Ext.util.DelayedTask(h);
var w = function(e){
fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
};
return w; };


At this moment fn is a function, but fn.task is undefined. This error may be achieved if we have two comboboxes in one grid and try to open both one after another or if we open and close a window and then try to open combobox (so may be second error is somehow tied to the first).

Seems that both errors are due to the new way of how GarbageCollector works.

Please, can't somebody suggest how can we fix this errors. I doubt it is easy to create a simple code to demonstrate them.

P.S. The first error I saw only in IE8, can't get it in FF, but the second saw both in IE and FF.

leonid1
26 Jan 2010, 4:49 AM
I've found the way to fix these errors.
The first one. You must change


El.addToCache = function(el, id){
id = id || el.id;
EC[id] = {
el: el,
data: {},
events: {}
};
return el;
};


to



El.addToCache = function(el, id){
id = id || el.id;
Ext.elCache[id] = {
el: el,
data: {},
events: {}
};
return el;
};


in Ext.EventManager. EC and Ext.elCache is't the same at this point. Real element cache isn't added. IMHO it's a bug.

The second error is fixed after changing



function createBuffered(h, o, fn){
fn.task = new Ext.util.DelayedTask(h);
var w = function(e){

fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
};
return w;
};


to



function createBuffered(h, o, fn){
fn.task = new Ext.util.DelayedTask(h);
var w = function(e){

if (!fn.task) {
fn.task = new Ext.util.DelayedTask(h);
}
fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);
};
return w;
};


in Ext.EventManager. I doubt it is right solution, but at least it works.

Radziu
18 Feb 2010, 12:35 AM
i had thesame problem with adding new record to the editorgrid and after edit value was fn is undefined: fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);.....

i solved it by commitChanges() afrer add/insert record

dorus
19 Feb 2010, 8:12 AM
[QUOTE=leonid1;431027]I've found the way to fix these errors.
The first one. You must change


El.addToCache = function(el, id){
id = id || el.id;
EC[id] = {
el: el,
data: {},
events: {}
};
return el;
};
to



El.addToCache = function(el, id){
id = id || el.id;
Ext.elCache[id] = {
el: el,
data: {},
events: {}
};
return el;
};
in Ext.EventManager. EC and Ext.elCache is't the same at this point. Real element cache isn't added. IMHO it's a bug.

I changed this but for me is not working, still getting the same result. Any suggestions?

madhuchowdary
22 Dec 2010, 9:27 PM
I changed this.for me it is working fine .thanks for solution.can any one please explian it breifly why this error is comimg.:)

amal.arindam
14 Jan 2011, 7:37 AM
Hi,
The solution above works, but sometimes it complains about EC[...].data is null or not an object. Is there a fix in already available? If yes, in which version of Ext JS?

leonid1
14 Jan 2011, 7:52 AM
Seems that it was fixed in Ext 3.3.1. After going to it I had never seen both of this error without any patches. In Ext 3.2.1 I've seen at least one of them.

amal.arindam
4 Mar 2011, 11:42 AM
I used Ext 3.3.1 and i still see the error on page load sometimes. Its not always. Is it really fixed in Ext 3.3.1?

madhuchowdary
6 Mar 2011, 9:12 PM
hi, to handle the error "EC[...].data is null or not an object" i modified e.addToCache method as follows.
for me it is working fine

n = n || m.id;
a=Ext.elCache;
Ext.elCache[n] = {
el :m,
data : {},
events : {}
};

amal.arindam
14 Mar 2011, 3:49 PM
Do we really need to modify the source ext files to get it working? I modified it last time in previous version to fix the issue. I thought it was fixed in version 3.3.1 but i still see the error. Shouldn't the source files have the fix in place?

madhuchowdary
14 Mar 2011, 8:30 PM
In new version also it is appearing,according to my understanding it is not fixed.for me no other option, so I modified ext files only

amal.arindam
15 Mar 2011, 10:13 AM
Hi,
Even after making the change i see it sometimes. Ext JS Forum Administrators,please take it to the right level please get it addressed.

amal.arindam
15 Mar 2011, 10:40 AM
Hi,
I had to make one more change to make it work. Below is the change. Had to replace EC with Ext.elCache in the below function.

El.data = function(el, key, value){
el = El.get(el);
if (!el) {
return null;
}
var c = Ext.elCache[el.id].data;
if(arguments.length == 2){
return c[key];
}else{
return (c[key] = value);
}
};

amal.arindam
15 Mar 2011, 12:33 PM
Small change to the code above.
El.data = function(el, key, value){
el = El.get(el);
if (!el) {
return null;
}
var c = [];
if(typeof Ext.elCache[el.id] == 'undefined'){
c = EC[el.id].data
}
else{
c = Ext.elCache[el.id].data;
}
if(arguments.length == 2){
return c[key];
}else{
return (c[key] = value);
}
};

madhuchowdary
15 Mar 2011, 8:34 PM
hi,
To make it work, only the above changes alone will work? or in addition to that the changes which i made also required? :)

jisaac01
19 Jul 2011, 10:25 AM
I applied the two fixes that looked relevant, to El.data and El.addToCache, but I still have a problem when getId is called.

I can't believe this is still a problem after 3 minor versions. There must be something deeper going on, like destroying a component too early.

jisaac01
19 Jul 2011, 12:57 PM
There must be something deeper going on

In my case, our javascript includes were duplicating some files (ext-all) and leaving others (ext-base) out. I'm actually not sure how I wasn't seeing more errors.