How to obtain table iterator with ColdFusion's Reactor?

10 views
Skip to first unread message

Erik Vold

unread,
Aug 24, 2011, 4:21:50 PM8/24/11
to reacto...@googlegroups.com
Is it possible to obtain a Iterator object for records in a table? something like a gateway object's getAll(), but called something like getAllIterator() or getIterator() ?

Thanks,

Tom Bishop

unread,
Aug 25, 2011, 11:27:43 AM8/25/11
to reacto...@googlegroups.com
Hi Erik,

I just posted something about this but I'm not sure if it's gone onto the mailing list yet. I think it answers your question though. This works with the getByFilter() method on a gateway object but allows you to return an iterator (which you can then call the getArray() method to return your query as an array of objects.

You have to alter some core reactor code though. Perhaps it could be committed to the next release if anyone likes it.

In the abstractGateway.cfc just replace:

<cfif format EQ "iterator">
                      <cfset r_Object = CreateObject("component",
"reactor.iterator.
BasicIterator").init(

getByQuery(QueryObj),

_getReactorFactory().createRecord(this.getObjectMetadata().getAlias())
                                                      )>
                      <cfreturn r_Object>
              </cfif>

with this:

<cfif format EQ "iterator">
                      <cfset r_Object = CreateObject("component",
"reactor.iterator.iterator").init(

_getReactorFactory(),

this.getObjectMetadata().getAlias())>
                      <cfreturn r_Object>
              </cfif>

You can the call your object like this:

<cfset myObjectIterator = reactor.createGateway("myObject").getByFilter(format="iterator")>
<cfset myObjectArray = myObjectIterator.getArray()>

Hope this helps,
Tom


--
You received this message because you are subscribed to the Google Groups "Reactor" group.
To post to this group, send email to reacto...@googlegroups.com.
To unsubscribe from this group, send email to reactor-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/reactor-users?hl=en.



--
Tom Bishop

http://www.webstoreinnovations.com

Reply all
Reply to author
Forward
0 new messages