David Harris's Technology Blog

ColdFusion, Flex, and other stuff...   (and 354,856 hours, 30 mins in to my plan for global domination)

Search:

Calendar:

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Subscribe:

Enter your email address to subscribe to this blog.

Archives By Subject:

Tags:

action script adobe air ajax cfug coldfusion flash flex frameworks free software fxug general jpgmetadatareader mac off topic opensource papervision spry

Recent Entries:

No recent entries.

Top Posts:

Recent Comments:

Top Commenters:

My Links:

RSS:


cfpresentation and "attributeCollection" issue

I've just been working with the new cfpresentation and cfpresentationslide tags.

These tags allow you to create dynamic, online presentations.

These tags allow you to use "attributeCollection" to pass in attributes, as do many (all?) of the tags in CF8 let you.

EG: Rather than

...
<cfpresentationslide title="This Slide" duration="15" ...[etc]... >

you can do this:

<cfset stAtts = structNew()>
<cfset stAtts.title = "This Slide">
<cfset stAtts.duration = "15"
...[etc]...

<cfpresentationslide attributeCollection="#stAtts#" >

What is great about this is that you can have conditional logic when defining the attributes, and only call the tag once.

Example: Without attributeCollection

<cfpresentation title="Example">
<cfif isDefined("audio")>
<cfpresentationslide title="slide one" audio="#audio#">
....[content of slide here]...
</cfpresentationslide>
<cfelse>
<cfpresentationslide title="slide one" duration="15">
....[content of slide here]...
</cfpresentationslide>
</cfif>
</cfpresentation>

With attributeCollection

<cfpresentation title="Example>
<cfset stAtts = structNew()>
<cfset stAtts.title = "Slide One">
<cfif isDefined("audio")>
<cfset stAtts.audio = audio>
<cfelse>
<cfset stAtts.duration = 15>
</cfif>
<cfpresentationslide attributeCollection = "#stAtts#">

....[content of slide here]...
</cfpresentationslide>
</cfpresentation>

Now, the issue: If you are looping over a query and use attributeCollection, and in the first slide have audio, and every slide after that, have no audio, the audio from the first slide is played on every slide afterwards.

This Code produces the issue:

<!--- Set up the query --->
<cfset qThisQuery   = queryNew( "title,duration,audio" )>

<!--- First row has MP3 and no duration --->
<cfset queryAddRow( qThisQuery )>
<cfset querySetCell( qThisQuery , "title" , "Slide 1")>
<cfset querySetCell( qThisQuery , "audio" , "cannedlaugh.mp3")>

<!--- Next rows have no audio, but a duration --->
<cfset queryAddRow( qThisQuery )>
<cfset querySetCell( qThisQuery , "title" , "Slide 2")>
<cfset querySetCell( qThisQuery , "duration" , "15")>

<cfset queryAddRow( qThisQuery )>
<cfset querySetCell( qThisQuery , "title" , "Slide 3")>
<cfset querySetCell( qThisQuery , "duration" , "15")>

<cfpresentation title="Example">

   <cfoutput query="qThisQuery">

      <!--- Create an empty struct and populate it with data for attributeColluection--->
      <cfset stAtts   = structNew()>      
      <cfset stAtts.title   = qThisQuery.title>
      
      <cfif len( qThisQuery.audio )><!--- We have a value here, so use it --->
      
         <cfset stAtts.audio   = qThisQuery.audio >
      
      <cfelse>
      
         <cfset stAtts.duration = qThisQuery.duration >
      
      </cfif>   
   
      <cfpresentationslide attributeCollection="#stAtts#" >
      
         <h1>#stAtts.title#</h1>
         <p>
            Here is the content of the presentation
         </p>
      
      </cfpresentationslide>
   
   </cfoutput>

</cfpresentation>

Attached is a zip that can be put in a CF8 instance and run to see the issue happening. :-)

The main reason for this blog is so I can refer to it when I log the issue with Adobe.

[Update] As per the comment below from Rupesh, the issue is logged as bug 70594

Related Blog Entries

Comments
Did you log a bug report? http://www.adobe.com/go/wish
# Posted By Raymond Camden | 10/17/07 9:43 AM
Hi Ray,

Yes I did.
Two reasons for this entry was:
1. the area for the bug info it quite small
2. You can't attach files when logging the issue.

So I did it here and put a link to this blog in the report.

Is it normal to get an issue number if they decide it *is* a bug?
If they do, I'll add it here :-)
# Posted By David | 10/17/07 8:20 PM
I don't think you will get a bug number - but I do think you will get an email if they confirm it. I think.
# Posted By Raymond Camden | 10/17/07 11:02 PM
David,
This is indeed a bug. I have logged bug no 70594. Thanks for bringing this to our attention.
Rupesh
Adobe ColdFusion Team
# Posted By Rupesh kumar | 10/18/07 1:03 AM
Hi Rupesh,

Thanks for the update :-)
# Posted By David | 10/18/07 6:38 AM
Well, you would think the StructNew(), being at the top of your loop, would fix that. Have you tried, in you 'no audio' condition, to see if the attribute exists and, if so, use StructClear() to remove it?
# Posted By Cutter | 1/14/08 8:11 AM
Hi Cutter,

Thanks for taking the time to comment.

I can't say that I did try what you suggested, but don't think it would make any difference.
As you pointed out, I am working with a new struct, do the "audio" key will not exist...

Cheers,

David
# Posted By David Harris | 1/14/08 7:00 PM