CFPRESENTATION inside a CFWINDOW

Posted At : November 9, 2007 11:44 AM | Posted By : Dave
Related Categories: ColdFusion 8

So, I wanted to create a dynamic cfpresentation and display it in inside a cfwindow. The concept seems very simple and straight forward. However, it was anything but. Creating the presentation was the easy part. The hard part was putting it into cfwindow. After a few failed attempts I got it working.

The first thing I tried was to simply put it the presentation in between the cfwindow tags. This was a test to see if the presentation would load in the window.

<CFWINDOW HEIGHT="480" WIDTH="640" MODAL="TRUE" CLOSABLE="TRUE" INITSHOW="TRUE">
   <CFPRESENTATION TITLE="Test Presentation" CONTROL="BRIEF" SHOWNOTES="NO" SHOWOUTLINE="NO" SHOWSEARCH="NO" AUTOPLAY="YES" LOOP="YES">
      <CFPRESENTATIONSLIDE DURATION="30">                     
         <IMG SRC="./testimage1.jpg" />
      </CFPRESENTATIONSLIDE>
      <CFPRESENTATIONSLIDE DURATION="30">                     
         <IMG SRC="./testimage2.jpg" />
      </CFPRESENTATIONSLIDE>
   </CFPRESENTATION>
</CFWINDOW>

What actually happened here was that the presentation loaded full screen outside of the cfwindow. In checking the source I see that the code for the cfwindow is there but no window was created.

My next attempt was to use ColdFusion.Window.create to generate a window and have it call a cfm file that generates the document.

<HTML><HEAD></HEAD><BODY>
<CFIF IsDefined('url.doPres')>
   <CFPRESENTATION TITLE="Test Presentation" CONTROL="BRIEF" SHOWNOTES="NO" SHOWOUTLINE="NO" SHOWSEARCH="NO" AUTOPLAY="YES" LOOP="YES">
      <CFPRESENTATIONSLIDE DURATION="30">                     
         <IMG SRC="./testimage1.jpg" />
      </CFPRESENTATIONSLIDE>
      <CFPRESENTATIONSLIDE DURATION="30">                     
         <IMG SRC="./testimage2.jpg" />
      </CFPRESENTATIONSLIDE>
   </CFPRESENTATION>
<CFELSE>
   <CFAJAXIMPORT TAGS="cfwindow">
   <SCRIPT LANGUAGE="JAVASCRIPT">
      ColdFusion.Window.create('Window1', 'Presentation Window', './index.cfm?doPres=1', {REFRESHONSHOW:true,height:480,width:640,modal:true,closable:true, draggable:true,resizable:false,center:true,initshow:true});
   </SCRIPT>
</CFIF>
</BODY></HTML>

This however, generated a never ending javascript error loop. The presentation was never loaded but the window appeared this time. Using Firebug, I verified that the window was in fact trying to load the presentation so I was making progress.

Since I had gone this far and was not about to give up. I had one more trick up my sleeve. This is a trick I used to get around the problem of cfwindow appearing on top of flash elements and having them bleed through. The time I decided to try and have the presentation load into an iframe inside the window.

<HTML><HEAD></HEAD><BODY>
<CFIF IsDefined('url.doPres')>
   <CFIF url.doPres EQ 1>
      <IFRAME SRC="./index.cfm?doPres=2" WIDTH="100%" HEIGHT="100%" FRAMEBORDER="0"></IFRAME>
   <CFELSE>
      <CFPRESENTATION TITLE="Test Presentation" CONTROL="BRIEF" SHOWNOTES="NO" SHOWOUTLINE="NO" SHOWSEARCH="NO" AUTOPLAY="YES" LOOP="YES">
         <CFPRESENTATIONSLIDE DURATION="30">                     
            <IMG SRC="./testimage1.jpg" />
         </CFPRESENTATIONSLIDE>
         <CFPRESENTATIONSLIDE DURATION="30">                     
            <IMG SRC="./testimage2.jpg" />
         </CFPRESENTATIONSLIDE>
      </CFPRESENTATION>   
   </CFIF>
<CFELSE>
   <CFAJAXIMPORT TAGS="cfwindow">
   <SCRIPT LANGUAGE="JAVASCRIPT">
      ColdFusion.Window.create('Window1', 'Presentation Window', './index.cfm?doPres=1', {REFRESHONSHOW:true,height:480,width:640,modal:true,closable:true, draggable:true,resizable:false,center:true,initshow:true});
   </SCRIPT>
</CFIF>
</BODY></HTML>

This time it actually worked. The presentation loaded inside the window as expected and worked. The presentation scaled nicely into the window. I did not notice any other issues by doing this. But I must admit I did not do much testing beyond getting it to load.

Until next time...

--Dave

Comments
<speculation>
I'm *guessing* here - but does cfpresentation use external JS libraries like flash forms do? If so, this blog post may help: http://cfsilence.com/blog/client/index.cfm/2007/8/...
</speculation>
# Posted By todd sharp | 11/9/07 1:02 PM
Hey I just noticed you have REFRESHONSHOW in your ColdFusion.Window.create(). Does that work? It's not documented anywhere...must it be ALL CAPS?
# Posted By todd sharp | 11/9/07 1:04 PM
It does use an external js library. That is probably what caused all the problems. As for the REFRESHONSHOW... As far as I can tell it does not work. I copied and pasted some test code for this so that is why it is here.

--Dave
# Posted By Dave Ferguson | 11/9/07 1:43 PM