'nuther noobe question Dynamic Query

5 views
Skip to first unread message

Sam Singer

unread,
Feb 17, 2010, 9:32:09 AM2/17/10
to cfwh...@googlegroups.com
Sorry for being a pest, CFWheels is just too much cool.  I gotta make it work!

I'm passing parameters from category-items/add to project-items/add.

The parameters aren't getting to the add function in the project-items controller.  Yet, at the bottom of the project-items/add page in debug I find:
URL Parameters:
categoryid = 2
categoryitemid = 117

So, the parameters should be getting to the add function, right?

I'm passing the parameters from the category-items/create.
Here's the relevant code:

<cfset redirectTo(action="add", controller ="projectItems", params = "categoryId = #categoryItem.categoryId#&categoryItemId = #categoryItem.Id#")>


Here's the relevant page results:

http://localhost:8500/slotc/index.cfm/project-items/add?categoryid = 2&categoryitemid = 117

Element CATEGORYID is undefined in PARAMS.

The error occurred in /Applications/ColdFusion9/wwwroot/slotc/controllers/ProjectItems.cfc: line 4
Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/global/cfml.cfm: line 130
Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/dispatch/request.cfm: line 381
Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/dispatch/request.cfm: line 348
Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/index.cfm: line 1
Called from /Applications/ColdFusion9/wwwroot/slotc/index.cfm: line 1
Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/events/onrequest.cfm: line 1

2 : <cffunction name="add" output="false">
3 : <cfset projectItem = model("projectItem").new()>
4 : <cfdump var="#params.categoryid#"> <cfabort>
5 :
6 : <cfset projects = model("project").findAllByCategoryId(params.categoryid)>


Thanks for any enlightenment!
--Sam Singer



tpet...@gmail.com

unread,
Feb 17, 2010, 10:06:28 AM2/17/10
to ColdFusion on Wheels
change your cfdump to just params and see what is getting injected
into the params struct and tell us what's in there:

<cfdump var="#params#"><cfabort>


On Feb 17, 9:32 am, Sam Singer <samsinge...@gmail.com> wrote:
> Sorry for being a pest, CFWheels is just too much cool.  I gotta make it
> work!
>
> I'm passing parameters from category-items/add to project-items/add.
>
> The parameters aren't getting to the add function in the project-items
> controller.  Yet, at the bottom of the project-items/add page in debug I
> find:
>

> *URL Parameters:*


> categoryid = 2
> categoryitemid = 117
>
> So, the parameters should be getting to the add function, right?
>
> I'm passing the parameters from the category-items/create.
> Here's the relevant code:
>
>  <cfset redirectTo(action="add", controller ="projectItems", params =
> "categoryId = #categoryItem.categoryId#&categoryItemId =
> #categoryItem.Id#")>
>

> *Here's the relevant page results:

> *


>  Element CATEGORYID is undefined in PARAMS.
>
> The error occurred in
> /Applications/ColdFusion9/wwwroot/slotc/controllers/ProjectItems.cfc:
> line 4
> Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/global/cfml.cfm:
> line 130
> Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/dispatch/request.cfm:
> line 381
> Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/dispatch/request.cfm:
> line 348
> Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/index.cfm: line 1
> Called from /Applications/ColdFusion9/wwwroot/slotc/index.cfm: line 1
> Called from /Applications/ColdFusion9/wwwroot/slotc/wheels/events/onrequest.cfm:
> line 1
>
> 2 :     <cffunction name="add" output="false">
> 3 :             <cfset projectItem = model("projectItem").new()>

> 4 :        *<cfdump var="#params.categoryid#">   <cfabort>*

Sam Singer

unread,
Feb 17, 2010, 10:30:32 AM2/17/10
to cfwh...@googlegroups.com
Changing the dump to <cfdump var=#params#> <cfabort> allows the page to execute with no errors.
I get the struct grid with the following:
action   add
categoryid   2
categoryitemid 102
controller   projectItems

But, if I let the following line execute, I get the same error.  Is my syntax not correct?


 <cfset projects = model("project").findAllByCategoryId(params.categoryid)>

--Sam Singer


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.


John C. Bland II

unread,
Feb 17, 2010, 10:40:37 AM2/17/10
to cfwh...@googlegroups.com
Your controller name is ProjectItems and you're setting a variable to projectItems. Most likely you're causing a conflict.

Put the findAll before "projectItems = ..." and see if that works. It seems fickle but I had that problem with method names and variable names so curious to see if the same exists for cfc names and variable names.

#spitballing

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"

Sam Singer

unread,
Feb 17, 2010, 11:11:31 AM2/17/10
to cfwh...@googlegroups.com
Thanks for the suggestions John, but it's still producing the same error.  I tried the following code which reverses the order of the two lines of code in order to avoid a possible conflict in method and variable names:

       <cfset projects = model("project").findAllByCategoryId(params.categoryid)>
       <cfset projectItem = model("projectItem").new()>
The error is still in the <cfset projects... line.

--Sam Singer

John C. Bland II

unread,
Feb 17, 2010, 11:26:43 AM2/17/10
to cfwh...@googlegroups.com
That's terribly odd.

Do you have any filters doing anything odd with params?
If you take everything else out of the function (or comment it) does the error occur?
Have you tried using url.categoryid instead of params?

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


Per Djurner

unread,
Feb 17, 2010, 11:29:00 AM2/17/10
to cfwh...@googlegroups.com
Does it have anything to do with the spaces in this part of your code?
params="categoryId = #categoryItem.categoryId#&categoryItemId =
#categoryItem.Id#"

On Wed, Feb 17, 2010 at 5:26 PM, John C. Bland II

Sam Singer

unread,
Feb 17, 2010, 11:41:00 AM2/17/10
to cfwh...@googlegroups.com
BINGO!
The spaces mattered.  Removing them make is work. For example, this is bad:  categoryId = #categoryItem.categoryId#
Here's the corrected code:

<cfset redirectTo(action="add", controller ="projectItems", params = "categoryId=#categoryItem.categoryId#&categoryItemId=#categoryItem.Id#")>

Thannks All for the help.  I'm still lovin' cfWheels!!!

--Sam Singer

John C. Bland II

unread,
Feb 17, 2010, 11:44:32 AM2/17/10
to cfwh...@googlegroups.com
Good deal. Figured it was something small.

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


Reply all
Reply to author
Forward
0 new messages