A reader wrote in to say that this code, which worked fine in ColdFusion 8, now refuses to center in ColdFusion 9:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<cfajaximport tags="cfwindow,cfform" />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>My Test Window</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script language="JavaScript">
loginwin = function(){
ColdFusion.Window.create('login', 'Account Login', 'login.cfm', {
modal: true,
closable: true,
draggable: true,
resizable: true,
center: true,
initshow: true,
width: 300,
height: 150
})
}
</script>
</head>
<body>
<a onclick="loginwin();">Open the window</a>
</body>
</html>
I thought perhaps it was the fancy DOCTYPE but removing that didn't help. The most I could guess at was some bug in the code used by the ColdFusion implementation. On a whim, I took a look at the Window object natively:
ob = ColdFusion.Window.getWindowObject('login')
console.dir(ob)
Lo and behold, there was a center function. So to correct this issue, you can just do:
ob = ColdFusion.Window.getWindowObject('login')
ob.center()
Archived Comments
Ray, you did not address the question why it was broke when there was already a center true in the calling parameters. Instread you looked under the hood and came up with a not so obvious way to make the center happen. Are we going to have to do that for the next 15 things that Adobe broke?
Err, well, I thought it was obvious. It's a bug. Adobe is as perfect as any other software company, Mark. ;) I'll make sure that this issue is reported and I'm sure it will be corrected. And yes - if someone finds 15 more bugs and workarounds, I hope someone does blog it, as it helps everyone.
Over the summer I submitted a bug to Adobe about the centering of cfwindows too. When you create a cfwindow using the tag, centering works just fine.
You can also play around with the X & Y cords and view port sizes of each browser.
<cfajaximport tags="cfwindow">
<script>
var Client = {
viewportWidth: function() {
return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
},
viewportHeight: function() {
return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
},
viewportSize: function() {
return { width: this.viewportWidth(), height: this.viewportHeight() };
}
};
function cleanup() {
ColdFusion.Window.destroy('mywindow',true);
}
function showWin(id) {
//do we have one?
try {
ColdFusion.Window.destroy('mywindow',true);
} catch(e) { }
var xcord = Client.viewportWidth()/2 - 350;
var ycord = Client.viewportHeight()/2 - 200;
ColdFusion.Window.create('mywindow',id,'content.cfm?q=' + id,{x:xcord,y:ycord,center:true,height:400,width:700,modal:true,closable:true,draggable:true,resizable:true,initshow:true});
ColdFusion.Window.onHide('mywindow',cleanup);
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1...">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<cfloop from="1" to="30" index="i" step="3">
<p><a href="javascript:showWin(<cfoutput>#i#</cfoutput>);">My Link</a></p>
</cfloop>
</body>
</html>
It seems that many things regarding ajax is broken. The Ext lib has been updated and this prevents backwards compatibility and the worst is that they didn't bother updating the documentation.
http://cfbugs.adobe.com/cfb...
Ok, so I know I'm an Adobe fanboy (never pretend not to be), but in their defense, CF9 was a major update in regards to the back end stuff for Ajax work. Most of the issues I've found were mainly with folks using the Ext API directly.
You say they didn't bother to update the documentation. That is wrong. You linked to a doc bug, which I agree with, but one bug does not mean the docs were not updated.
Ray, in my case, cfwindow is also broken under CF9. It was working perfect in our production (CF8) environment. I havent looked at ajax portion yet, but cfwindow is definitely acting weird.
Have you checked the release notes? If so and it's new, have you logged a bug w/ an example?
I havent checked the release notes nor i've filed a bug report. I'm installing win7 today on local pc's. I'll priortize this issue next.
Ray, just to let you know the status, I was able to fix cfwindow issue by looking over my code.
Hi,
Please make sure to file your bugs in the public bugtracker and we will try to resolve the same. The public bugtracker is hosted at www.adobe.com/go/CF_bugs
The CF 9.01 Update seems to have fixed the issues I was having with CF Windows. Once applied everything worked properly.