Hi all,

I've updated to Doug's Reactor BC and I remember reading something about changes being made to the way iterators handle getOrder(). Below is the function I am using to get a page of results and return then into a MG value:

    <cffunction name="getVideoPage" access="Public" returntype="void" output="false" hint="I get a Page of Videos.">
        <cfargument name="event" type=" ModelGlue.Core.Event" required="true" />
        <cfset var OrderBy = arguments.event.getValue("OrderBy","Video") />
        <cfset var OrderDir = arguments.event.getValue ("OrderDir","ASC") />
        <cfset var startRow = arguments.event.getValue("startRow","1") />
        <cfset var numRecords = arguments.event.getValue("numRecords","10") />
        <cfset var searchBy = arguments.event.getValue("searchBy") />
        <cfset var searchFor = arguments.event.getValue("searchFor") />
        <cfset var VideoIterator = Reactor.createIterator("Video") />
        <cfset var VideoPage = 0 />
            <cfif searchBy NEQ "">
                <cfset VideoIterator.getWhere().isLike("Video",searchBy,searchFor) />
            </cfif>
            <cfset arguments.event.setValue("TotalRecords",VideoIterator.getRecordCount()) />
            <cfif OrderDir EQ "DESC">
                <cfset VideoIterator.getOrder().setDesc("Video",OrderBy) />
            <cfelse>
                <cfset VideoIterator.getOrder().setAsc("Video",OrderBy) />
            </cfif>
            <cfset VideoPage = VideoIterator.getQuery(val(startRow),val(numRecords)) />
            <cfset arguments.event.setValue("VideoPage",VideoPage) />
    </cffunction>

but I'm getting the following error:

Oops!

Message Can Not Get Order
Detail Calls to getOrder are not allowed after getting an iterators query or array data. You must call reset first, which reset any changes you have made to objects in the iterator.
Extended Info
Tag Context D:\Inetpub\wwwroot\Reactor\iterator\iterator.cfc (780)
D:\Inetpub\wwwroot\jjVideos\controller\VideoController.cfc (38)
D:\Inetpub\wwwroot\ModelGlue\ModelGlue.cfc (482)
D:\Inetpub\wwwroot\ModelGlue\ModelGlue.cfc (379)
D:\Inetpub\wwwroot\ModelGlue\ModelGlue.cfc (336)
D:\Inetpub\wwwroot\ModelGlue\ModelGlue.cfc (296)
D:\Inetpub\wwwroot\ModelGlue\ModelGlue.cfm (64)
D:\Inetpub\wwwroot\jjVideos\index.cfm (27)

So the question is, what do I need to change to make this still work?
-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

Reply via email to