Thanks Simeon. I have used the hasNext before. The issue though is that
the array in this case would be an array of categories, so the delete
would be deleting the category record and not the relationship in the
linking table (unless I am missing something). My question is, how do I
remove the relationship (i.e. this resource no longer has this
category)? The code I listed was removing the relationship record, but
I cannot seem to find an easy way to do this since the resource object,
in this case, doesn't return any references to the relationship table
(sorry if that isn't very clear...I am finding it hard to describe
this).
- Brian
Simeon Bateman wrote:
Hey Brian,
I tend to use a conditional loop which binds on the itterator s
hasMore() ( or was it hasNExt? sorry not code in front of me) method.
But withouth changing much in your code I think you could just do like
this
<cfset arrCurrentCategories =
reactorFactory.createIterator("resource").getArray() />
and then loop over your array much the same as you do now.
Hope that helps.
simeon
On 3/26/06, Brian Rinaldi <[EMAIL PROTECTED]>
wrote:
Hi
all, I updated to a recent SVN copy of Reactor, and I am trying to
update my code for the open-source list to accommodate the changes that
have been made. The one area I am having trouble with is in the area of
the iterator and linking tables. It appears that in the old method, you
could still get the records for the linking table, but now you only get
the records for the objects that the linking table is linking to (and
while I am explaining this rather poorly, it does actually make more
sense). So, I had a "resource" object that had many categories via a
linking table. My form would handle this by getting the array of
resourceCategories (i.e. the linking table records) and verifying that
you haven't deselected any in the multiple select box in the form that
were previously selected like this:
<!--- delete any existing categories no longer on the list --->
<cfset arrCurrentCategories =
resource.getOpenSourceResourceCategoriesArray() />
<cfloop from="1" to="#arrayLen(arrCurrentCategories)#" index="i">
<cfif NOT
listFind(form.categoryID,arrCurrentCategories[i].getCategoryID())>
<cfset arrCurrentCategories[i].delete() />
</cfif>
</cfloop>
I am wondering how to handle this type of situation now. What has
changed is that the iterator will give me either a query or array of the
categories, and not the linking table records (unless I am completely
dense and missing something). I have a couple of ideas, but they all
seem to involve a decent amount of additional coding, so I was hoping
someone might be able to direct me on the right path. (if you want the
full code I am discussing, this was my Getting Started with Reactor
post
from February -
http://www.remotesynthesis.com/blog/index.cfm/2006/2/17/Getting-Started-with-Reactor)
Thanks.
--
Brian Rinaldi
blog - http://www.remotesynthesis.com/blog
ColdFusion Open Source List -
http://www.remotesynthesis.com/cfopensourcelist
Boston ColdFusion User Group - http://www.bostoncfug.org
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
--
Brian Rinaldi
blog - http://www.remotesynthesis.com/blog
ColdFusion Open Source List - http://www.remotesynthesis.com/cfopensourcelist
Boston ColdFusion User Group - http://www.bostoncfug.org
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
|