A couple weeks ago I wrote a post on Enhancing CFWindow with JavaScript, and it was recently asked if there was a way to identify all the windows and their visible status that currently exist on a page where you are using the ColdFusion.Window.create function to create new CFWindow instances. It took a few minutes of digging with FireBug, but I found that there is a ColdFusion.objectCache object that holds information about the various ext object that get created with the ColdFusion AJAX features. I created a function that loops through the objectCache and finds objects that have a "cfwindowname" property. Then used the Ext.BasicDialog.isVisible() function to determine if the window is currently visible.
You can see this working sample here. First press the "Show CFWindow Names" button and it will show you that Window 1 and 2 are visible. Then press the "Create Window3" button and click the "Show CFWindow Names" again and you will see that there are now three visible windows, if you close window 1 or 2 and click "Show CFWindow Names" button it will tell which windows are now hidden.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>CFWindow</title>
<script language="JavaScript">
showWindowNames = function(){
for(sProperty in ColdFusion.objectCache)
{
if(ColdFusion.objectCache[sProperty].cfwindowname != 'undefined'){
thisWindow = ColdFusion.Window.getWindowObject(sProperty);
if(thisWindow.isVisible()){
alert("There is a visible cfwindow named " + sProperty);
}
else{
alert("There is a hidden cfwindow named " + sProperty);
}
}
}
}
</script>
</head>
<body>
<cfwindow
name="MyWindow"
center="true"
closable="true"
draggable="true"
height="500"
initShow="true"
minHeight="100"
minWidth="200"
modal="false"
refreshOnShow = "false"
resizable="true"
title="My Test Window"
width="400">
window contents
</cfwindow>
<cfwindow
name="MyWindow2"
center="true"
closable="true"
draggable="true"
height="400"
initShow="true"
minHeight="100"
minWidth="200"
modal="false"
refreshOnShow = "false"
resizable="true"
title="My Test Window2"
width="400">
window contents
</cfwindow>
<form name="MyForm">
<input type="button" value="Show CFWindow Names" onclick="showWindowNames();">
<input type="button" name="createWindow" value="Create Window3"
onClick="ColdFusion.Window.create('MyWindow3', 'My Test Window3','',{x:100,y:100,height:300,width:400,modal:false,closable:false,draggable:true,resizable:true,center:true,initshow:true,minheight:200,minwidth:200})">
</form>
</body>
</html>