Jeff – The errors says it all. After
you call getQuery or getArray you can’t change its order or where clause.
This allows for the addition of features such as adding elements into the iterator
and saving them.
You’ll most likely run into this
issue if you have a cached iterator that you try to sort each time you use it.
There’s a method on the iterator,
reset(), which resets the iterator and will allow you to re-sort it.
Doug
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Jeff Lester
Sent: Saturday, April 29, 2006
4:21 AM
To: [email protected]
Subject: [Reactor For CF] Re:
Iterator getWhere() and getOrder()
No ideas? I searched the
archives...
On 4/29/06, Jeff
Lester <[EMAIL PROTECTED]>
wrote:
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/
-- Reactor for ColdFusion Mailing List --