The more I play with Spry, the more I like it. I'd like to show you one more demo...
http://ray.camdenfamily.com/spry/blog3.cfm
I've added two cool things here. First is the alt-table row colors. This is done by Spry's support for conditionals. Here is the code behind it:
2 <tr spry:if="({ds_RowNumber} % 2) == 0" class="even" onclick="dsEntries.setCurrentRow('{ds_RowID}');" >
3 <td>{TITLE}</td>
4 <td>{POSTED}</td>
5 <td>{COMMENTCOUNT} </td>
6 </tr>
7 <tr spry:if="({ds_RowNumber} % 2) != 0" class="odd" onclick="dsEntries.setCurrentRow('{ds_RowID}');" >
8 <td>{TITLE}</td>
9 <td>{POSTED}</td>
10 <td>{COMMENTCOUNT} </td>
11 </tr>
12 </tbody>
Notice the spry:if check. This handles checking the current row number and using a different CSS class for each row. Nice and simple. The only thing I wasn't sure about was how to use it. The last version applied the spry:repeat to the TR tag. Since I needed the condition in the TR, I wasn't sure how they would mix. One of the Spry demos showed the technique above though and it worked like a charm.
In the zip you can download from Adobe, they have a few additional examples not demonstrated on the Labs site. One is pagination. View source on the demo to see the JavaScript behind it. Just to be clear - I didn't write this. I simply cut and pasted from the example in the zip, but I'm again impressed with how simple this is. Note the use of the filter function in the xml call:
You can obviously filter by other methods as well. Anyway, check it out, view source, and enjoy. I didn't update the zip, but the only change to the CFC was that I upped the max number of results to 100 so that paging would actually work.
Comment 1 written by Justice on 13 June 2006, at 12:22 PM
Maybe I am just a bit slow, but why would you want to re-invent the wheel like this? Everything this Spy does could be done with JS and CF currently, and with tags I know now.
I'm not trying to be an ass, but why would I want to take the time to learn how to write in Spry?
Comment 2 written by Scott Stroz on 13 June 2006, at 12:36 PM
Comment 3 written by Raymond Camden on 13 June 2006, at 12:42 PM
Comment 4 written by Justice on 13 June 2006, at 12:51 PM
Someone must make one language to rule them all, a nice english based one.
'Create a report to show me my revenue from 2006' BAM! =)
Comment 5 written by Raymond Camden on 13 June 2006, at 12:52 PM
Comment 6 written by Neil Bailey on 13 June 2006, at 3:21 PM
I have been using Flash forms (actually, we've been using them EVERYWHERE, and it was a mistake), and we're just starting to move over to AJAX-ified forms instead. Currently we're using CFAJAX, and its...ok....
How difficult was it to integrate SPRY w/ your ColdFusion CFCs?
Comment 7 written by Raymond Camden on 13 June 2006, at 3:31 PM
First, my CFCs were returning "normal" data. Queries, arrays, etc. Spry wants XML. So I just built a helper function or two to convert queries/arrays to XML. Problem solved.
Second, when you return XML from a CFC, the CFC will still WDDX encode it. You need to ensure you do returnType="xml" in order for the CFC to not WDDX encode stuff. See my zip in the last entry.
Comment 8 written by adam on 13 June 2006, at 10:35 PM
Comment 9 written by Raymond Camden on 14 June 2006, at 8:37 AM
Comment 10 written by Will on 15 June 2006, at 5:16 PM
Comment 11 written by Raymond Camden on 15 June 2006, at 5:29 PM
Comment 12 written by Will on 16 June 2006, at 11:54 AM
Comment 13 written by Mike on 6 July 2006, at 2:45 AM
Comment 14 written by Raymond Camden on 6 July 2006, at 6:41 AM
The Spry team is -very- aware that the documentation needs work. It will happen. Do not forget it is still pre-release software. I tend to forget to remind folks that when I'm gushing about the software.
Comment 15 written by Chris on 11 December 2006, at 1:22 PM
Im new to SPRY and the blog examples have helped me greatly and I thank everyone who's contributed.
I have a situation where Id like to only trigger SPRY/AJAX
queries based on a javascript function but have been unable
to figure out how to implement it.
In specific; Im sending some parameters from an existing
FLASH SWF via the FSCommand with the intent of showing some
record details outside the flash object on the same html page.
Has anyone triggered the SPRY functions from within another
JS Function???
I've tried embedding the Spry.Data.XMLDataset constructor
like...
var dsCerts = new Spry.Data.XMLDataSet("spry_cert_records2.cfm?ID=" + args,"certs/cert");
within the FSCommand reciever function but this doesn't work..
any hints would be greatly appreciated
Chris
Comment 16 written by Raymond Camden on 11 December 2006, at 8:32 PM
Comment 17 written by Chris on 18 December 2006, at 7:30 AM
Im trying to trigger a detail region query from within
the javascript function..
function looks like this:
function myFlash_DoFSCommand(command, args) {
var myFlashObj = InternetExplorer ? myFlash : document.myFlash;
alert (args);
var lccObjs = new Spry.Data.XMLDataSet("spry_lccobj_records.cfm?id=" + args,"objs/obj");
<!--- var dsCerts = new Spry.Data.XMLDataSet("spry_cert_records2.cfm?ID=23","certs/cert"); --->
}
and detail region looks like this
<div id="Layer1">
<div id="Obj_Detail" spry:detailregion="lccObjs" class="bigbox">
<p><span class="style1">Object ID ---- Object Name -- Object Position</span> <br />
{OBJ_ID} - {OBJ_NAME} - {POSITION} <br />
</p>
<p><span class="style1">Comments</span><br />
{COMMENTS}</p>
<p><span class="style1">X Location:{XLOC} Y Location:{YLOC}</span></p>
URL=<a href="{CERT_LINK}" terget="_blank">{CERT_LINK}</a><br />
</div>
</div>
error report is:
Control Room Equipment Viewer
Object ID ---- Object Name -- Object Position
{OBJ_ID} - {OBJ_NAME} - {POSITION}
Comments
{COMMENTS}
X Location:{XLOC} Y Location:{YLOC}
URL={CERT_LINK}
spry:region or spry:detailregion attribute has no data set!
spry:region or spry:detailregion attribute has no data set!
Comment 18 written by Raymond Camden on 18 December 2006, at 8:27 AM
var dsCerts = new Spry.Data.XmlDataSet("", "");
Comment 19 written by Chris on 18 December 2006, at 1:22 PM
(im still getting errors from the detail region's field names.. .. like
processTokens(): Value reference has no data set specified: {OBJ_NAME}
but i should be able to figure that out
thank you again ... oh CF/JS Wizzard
Comment 20 written by Duane Hardy on 28 February 2007, at 5:09 PM
I am trying to do this presently and I am struggling with getting the data back into the dynamic regions. I am presently have a form that sends the form variables (keyword) to xmlproxy.cfc and returns the xml document filtered by the "keyword". The problem is I can't get it to show up in the dynamic regions.
How do I get the xml back into the dymamic regions. I think you in advance for any help you might give.
Comment 21 written by Raymond Camden on 28 February 2007, at 8:44 PM
However - you can also filter on the client side. For that - I'd point you to the docs. :) It is doable and the Spry folks have good docs on it. Oh - a good online example - RIAForge. That search has a text field that filters as well.
Comment 22 written by Kalen Gibbons on 25 October 2007, at 6:28 PM
Comment 23 written by Raymond Camden on 25 October 2007, at 7:53 PM
Comment 24 written by Dav R on 11 November 2009, at 11:39 AM
The demo page http://ray.camdenfamily.com/spry/blog3.cfm
is not working. Plz fix :-)
Comment 25 written by Raymond Camden on 11 November 2009, at 1:39 PM
[Add Comment] [Subscribe to Comments]