[ColdBox 4.2.0] Global query to use on all views

19 views
Skip to first unread message

Marc Rohrer

unread,
Jul 14, 2016, 11:46:28 AM7/14/16
to ColdBox Platform
Hello,

I would like to include a global query for use on all views. I thought I could do this with an interceptor, which might be true and maybe I'm setting the result set incorrectly. What is the proper way to set a global query for inclusion on views.

Thanks,
Marc

br...@bradwood.com

unread,
Jul 14, 2016, 11:54:46 AM7/14/16
to col...@googlegroups.com
I would recommend setting the query into the prc scope (private request collection).  The easiest way to do this is in a preProcess interceptor or in your requestStartHandler handler.
 
Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/a4b46d04-2c4f-4b46-ae59-194222caf10f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Rohrer

unread,
Jul 14, 2016, 12:32:30 PM7/14/16
to ColdBox Platform
Thanks for the quick response, Brad.

I had originally tried the preProcess on the interceptor with setting it to prc. But the view does not see it. Do I need to call it differently on the view instead of using prc? And interesting enough, the postProcess does see the query created in the preProcess. So I'm not sure why the view doesn't.

Attached is my interceptor. Maybe I'm missing something.

Thanks,
Marc
authentication.cfc

br...@bradwood.com

unread,
Jul 14, 2016, 12:48:55 PM7/14/16
to col...@googlegroups.com
prc is not an argument to interceptors (yet anyway-- I think Luis put in a ticket for that recently) so what you're acttually setting is variables.prc.get_participant!
 
You need to do
event.setPrivateValue( 'get_participant', etc.getParticipant(...) )
or just get out the prc like so:
 
var prc=event.getPrivateCollection.
prc.foo = bar;
 
The reason you're used to this "working" in handlers is that we pass prc in as an argument to the methods so every time you access it, you're actually accessing arguments.prc.
--------- Original Message ---------

br...@bradwood.com

unread,
Jul 14, 2016, 1:12:12 PM7/14/16
to col...@googlegroups.com
Opps, 
 
var prc=event.getPrivateCollection.
 
should have read
 
var prc=event.getPrivateCollection();
--------- Original Message ---------

Marc Rohrer

unread,
Jul 14, 2016, 1:23:03 PM7/14/16
to ColdBox Platform
Thanks Brad!!

That worked great! And thanks for the explanation, which will help me.

Marc
Reply all
Reply to author
Forward
0 new messages