|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
CFGRID - using object in memory with bind attribute?
I recently jumped back into CFGRID after not looking at it for a long time; what I was able to whip up in short order seems like a very good fit for what I'm working on.Doug Smidt 01/07/09 04:14 P Why not point to a CFC that uses the object in memory? Or am IRaymond Camden 01/07/09 05:16 P So I'm confused - are you saying the only reason you don't want to useRaymond Camden 01/07/09 06:14 P I do want to use a persisted CFC....but I want to use it on the spot, in the CFGRID tag. I don't want to:Doug Smidt 01/07/09 07:18 P > I do want to use a persisted CFC....but I want to use it on the spot, in the CFGRID tag. I don't want to:Raymond Camden 01/08/09 10:08 A This isn't my argument - it's yours. I'm not going to get into another endless debate on best practices.Doug Smidt 01/08/09 11:52 A I recently jumped back into CFGRID after not looking at it for a long time; what I was able to whip up in short order seems like a very good fit for what I'm working on. One thing I wasn't able to figure out (or even know if it's possible)...is there a way to provide an object in memory to the bind attribute instead of a path to a CFC? Almost all of our CFCs require other objects be tucked in using dependency injection before they'll do their thing, which means simply providing a path isn't an option for me unless I create a separate, non-conforming CFC to do my work. Is this an option, am I missing something really simple, or am I chasing a pot of gold here? Why not point to a CFC that uses the object in memory? Or am I misreading you? There is no need for the CFC you call to rerun cfquery. It can simply use an application (or session, whatever) cached query and perform QofQ on it for sorting. > I recently jumped back into CFGRID after not looking at it for a long time; what I was able to whip up in short order seems like a very good fit for what I'm working on. > > One thing I wasn't able to figure out (or even know if it's possible)...is there a way to provide an object in memory to the bind attribute instead of a path to a CFC? Almost all of our CFCs require other objects be tucked in using dependency injection before they'll do their thing, which means simply providing a path isn't an option for me unless I create a separate, non-conforming CFC to do my work. > > Is this an option, am I missing something really simple, or am I chasing a pot of gold here? Sorry - I should have been more clear. I'm not necessarily referring to an object (variable) in a shared scope, though I want that to be an option. I also don't want to have to access a variable containing my CFC directly from a shared scope inside of another CFC. A very basic, quick example of what I would like to be able to do. I have a CFC called People. That CFC has a couple of queries in it; one to get people and another to update a person. My Person CFC requires a Datasource object be passed in via dependency injection to work. I create a variable called called MyDatasource on a .cfm page, I create a variable called MyPeeps, then I inject MyDatasource into MyPeeps. MyPeeps can get people from my database and update a person in my database. My cfgrid tag has these attributes: bind="cfc:somepath.People.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})" onchange="cfc:somepath.People.editData({cfgridaction},{cfgridrow},{cfgridchanged})" Instead of using "somepath.People", I'd like to use a variable I've created containing my CFC (MyPeeps) instead of a path to a CFC. Similar to what you can do with a CFINOVOKE tag. Like I said, I don't know if this is even possible...but I figured it couldn't hurt to ask. I don't know what goes on behind the scenes with CFGRID, so it may just not work. I can get it done without it....but that will require me to split up files I didn't want to split up. If I must, I must. ----- Excess quoted text cut - see Original Post for more ----- So I'm confused - are you saying the only reason you don't want to use a persisted CFC is.... what? Why isn't this CFC (myPeeps) cached in the app scope? You could then make another CFC, just for AJAX purposes, that works with this app scoped CFC. I know that - in general - folks recommend against that, but for AJAX I think it makes sense. The CFC is simply acting as a proxy to your cached components. ----- Excess quoted text cut - see Original Post for more ----- I do want to use a persisted CFC....but I want to use it on the spot, in the CFGRID tag. I don't want to: 1) Do exactly what you stated is generally recommended against. I don't want to be accessing a shared scope directly in a CFC. I've taught others not to do it, and I'm not going to do it either. 2) I already have a perfectly good CFC that does everything I need it to do, but I can't use it because I can't instantiate it properly. It's not a static CFC. I don't want to have to write another CFC with the sole purpose of accessing a variable that does everything I need if I don't have to. I know what my options are, but you're not answering my question, which is simply this. Is there any way I can use a variable in the bind attribute instead of a path to a CFC? ----- Excess quoted text cut - see Original Post for more ----- > I do want to use a persisted CFC....but I want to use it on the spot, in the CFGRID tag. I don't want to: > > 1) Do exactly what you stated is generally recommended against. I don't want to be accessing a shared scope directly in a CFC. I've taught others not to do it, and I'm not going to do it either. But the fact is - many "Dont do X" rules have exceptions. This is one of them. ColdSpring even provides for this out of the box (taking your configured services and creating remote proxies for them). I don't think your argument here is valid. > I know what my options are, but you're not answering my question, which is simply this. Is there any way I can use a variable in the bind attribute instead of a path to a CFC? You can use a query in the HTML grid. If your CFC lets you get the query object, just get it, and do query="#...#" in your cfgrid tag. -- =========================================================================== Raymond Camden, VP of Software Dev, Broadchoice Email : ray@camdenfamily.com Blog : www.coldfusionjedi.com AOL IM : cfjedimaster Keep up to date with the community: http://www.coldfusionbloggers.org This isn't my argument - it's yours. I'm not going to get into another endless debate on best practices. Simply dropping my data into the query attribute doesn't solve my problem, as I need the same thing to happen in the onChange attribute. I'm not aware of a replacement for that, and what I have running is pretty kick-ass from a user POV. I just don't like how my code looks. So I'll ask again - Is there any way I can use a variable in the bind (or onChange) attribute instead of a path to a CFC? That's all I want an answer to. If the answer is yes, how do you do it? If it is not, a simple explanation as to why not. But a simple yes or no will do. ----- Excess quoted text cut - see Original Post for more ----- ======> ===================================================================== > Raymond Camden, VP of Software Dev, Broadchoice > > Email : ray@camdenfamily.com > Blog : www.coldfusionjedi.com > AOL IM : cfjedimaster > > Keep up to date with the community: http://www.coldfusionbloggers. org
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||