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.

Share this post:
  • Print
  • email
  • Facebook
  • Twitter
  • Tumblr
  • del.icio.us
  • Digg
  • Reddit
  • Sphinn

Related Posts

This entry was posted in ColdFusion, Javascript and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
blog comments powered by Disqus
  • Subscribe to my feed Subscriber via Email Follow Me on Twitter! Check me out on Facebook! Check me out on LinkedIn!