ColdFusion 8 CFWindow caching problem

This iteration of ColdFusion is absolutely wonderful. Now anyone can AJAX and look like a DHTML guru with just a few lines of code. A previous post outlined the problem of not being able to refresh the CFWindow content. CF8 uses the EXT js library as of version 1.1.1 (I think) which by default does not provide a way to refresh the content of an element without actually manipulating the body property of the BasicDialog object. In CF the problem is even more complicated because you cannot just destroy a window and recreate it. There is no means to directly do this, so you have to access the underlying Ext library and call the destroy() function on the dialog. However, if you try to create a new window with the same name you get a javascript error. This is because the object is cached in the ColdFusion.objectCache object. Now, this is a good thing but the problem is that you cannot destroy the window easily. I would think this is a common task and should have been added. To work around the problem, you have to remove the element from the cache...

// get a reference to the Ext object
var mywin = Coldfusion.Window.getWindowObject('my-window-1');

// destroy the window and remove the elements from the DOM
mywin.destroy(true);

// remove the element from the ColdFusion.objectCache
ColdFusion.objectCache['my-window-1'] = null;

This would allow you to recreate the window via script without any problems. I think this is a serious oversight and a function should be added to allow for this operation.

The ColdFusion.objectCache is a very handy tool and should have better documentation.

Related Posts

This entry was posted in ColdFusion, Javascript and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Misty

    but if i use Coldfusion.Window.distory(), does it behave the Same Odd way still it keeps the cache or it actually destroys then. I am using Coldfusion 8.01 version a Patched one

  • Anonymous

    Sorry for the delay in replying, I’ve actually not use these functions recently so I can’t tell you for certain but as of 8.0.1 I believe there was the same version of Ext JS library in use so the problem should still exist. I mostly use jQuery these days.