Spry Ratings Widget
The release of Spry 1.6.1 didn't ensure the continued support for Adobe AIR but also came with a new widget called the ratings widget.
A little Ajax widget with some potential to be entirely over-used at least by me. As with most Spry widgets its ridiculously easy to use and setup. But not wanting to stop there I decided to create a custom component that would make it even easier oh and hook into a database to save the results (mySql only at this point).
I still need to clean up the code a little bit and add a few more features, but will put it up on RIAForge when it's prettier and documented :).
Currently to create a Spry Rating Widget you need one line of code:
<cfoutput>#createobject("component","rating").newWidget('ratingwidget','Rate this Post!',5,'../assets/js/','../assets/css/')#</cfoutput>
Resulting in widget that looks like:
The function header looks like this:
<cffunction name="newWidget" access="public" output="true" returntype="void">
<cfargument name="ratingName" type="string" required="true" hint="This should be unique">
<cfargument name="ratingTitle" type="string" required="true" hint="Title that will appear to the user">
<cfargument name="ratingNumber" type="numeric" required="true" hint="Max number of stars">
<cfargument name="pathToSpryJS" type="string" required="true" hint="relative or absolute web path to Spry widget JS files">
<cfargument name="pathToSpryCSS" type="string" required="true" hint="relative or absolute web path to Spry widget CSS files">
I decided to make the path to the Spry CSS and JS as separate arguments to provide the most flexibility in directory structure. The argument list will probably grow a little bit more as I add a few more features but those will probably become optional parameters.
Happy coding...

Subscribe
Subscribe via RSS
Follow me on Twitter
Or, Receive daily updates via email.
Tags
adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript jquery max2007 max2008 misc open source programming railo software technology ui
Recent Entries
No recent entries.
Blogroll
An Architect's View
CFSilence
Rey Bango
TalkingTree

If you have put the code for the Spry
Ratings in RIA could you share it with me please?
Thanks You
You can find the widget here http://cfcspryrating.riaforge.org/
These are my first baby-steps with SpryRanding and actually with
ColdFusion itself. So I would like to undestand the widget following Adobe
Docs before using your CFC. See if you can help and bear with me :
<span id='rating1' class="ratingContainer">
<span class="ratingButton"></span>
.....
.....
<span class="ratingButton"></span>
<span class="ratingRatedMsg">MessageOne</span>
<span class="ratingReadOnlyErrMsg sample">MessageTwo</span>
</span>
<script>
var rate = new Spry.Widget.Rating('rating1', {postData: 'id=08C335F3-874D-9864-A7FB3F325223EC5B&userId=EFFF96F5-874D-9864-A39198B7E1A3DF15&val=@@ratingValue@@', saveURL:'ratingSave.cfm'});
//var rating1 = new Spry.Widget.Rating('rating1', {saveURL:'ratingSave.cfm?id=08C335F3-874D-9864-A7FB3F325223EC5B&userId=EFFF96F5-874D-9864-A39198B7E1A3DF15&val=@@rw_Rating@@'});
</script>
The file "ratingSave.cfm" exists in the same directory and if used by itself saves data as expected, but using either methods POST or GET "ratingSave.cfm" is not found at all. Buttons are shown properly and no error message is returned.
Please advice. Thank You.