Using ColdBoxProxy for Ajax Calls (v3 M5)

I'm trying to use the ColdBoxProxy to make Ajax calls and seem to have
got the basic functionality working although I've change one small
part of the code sample in the docs from...

cbox.process(event:'artists.list');

...to...

cbox.process(event='artists.list');

...as I was getting the JavaScript error...

Error: missing ) after argument list
Source File: http://www.localhost/
Line: 69, Column: 25
Source Code:
       cbox.process(event:'artists.list');

...and now get a simple response as expected.

My question is: how can I pass, I assume, URL vars to the event
handler, artists.list, for it to use in it's processing.

My exact scenario is that I'm catching a form submit with jQuery and
want to pass the form vars to the remote event and then display an
appropriate messing in a modal window.

I did try some self-help and found references to the cf8ajax sample
app but can't seem to find that anywhere (URL?).

Hi Herbert,

you use the process() method to proxy in an event. Basically the arguments you pass will be transformed into the request collection. However, one of the arguments must be the ‘event’ you want to execute. Example:

process(event=“artists.list”, artistID=1, page=2)

That will execute the artits.list event and the artistID and page variables in the request collection. Is this what you where looking at?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Hi Luis,

Yes, that's exactly what I'm looking for. Although your suggestion sounds
ideal it doesn't seem to work for me.

Not only does it seem to be more reliable if you quote the values like...

process(event="artists.list", artistID="1", page="2")

...they don't seem to get into the request collection rc of the event
handler...

"Element ARTISTID is undefined in RC."

Ciao for now,

Richard

Hi Luis,

I've managed to crack this one myself!

I was missing the requirement to collect the arguments first in my
ColdBoxProxy.cfc from the JavaScript proxy call before passing it onto yours
via super.process()

Outside the the slight typo in the doc's all's working as expected.

Thanks for your insight which helped me progress :slight_smile:

Ciao for now,

Richard

Ahhh sorry, I thought that was CF and not javascript.

Here is another important caveat I had to found out the hard way. If you use cfajaxproxy, please make sure you bind it to methods that are not the proxy’s process() method. Why? Because it needs strong typed arguments and not virtual arguments like the process() method. Plus, calling the process method directly as a remote event is bad practice. I recommend creating good remote API methods that have distinct arguments as you are exposing those to the outside world.

I hope this helps, as I went through long hours of shouting and going crazy until I discovered that cfajaxproxy needs the same arguments in CF to map to JS.

Ciao

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Yes, that's how I have my code arranged. I have my own proxy which calls the
CB proxy.

But I'm glad you mentioned it because I just hit an issue with IE8 users
hitting the page...

"Message: Member not found"

After many "hours of shouting and going crazy" I remembered your wise words
and forced all the argument names to upper case...

cbox.process(EVENT="artists.list", ARTISTID="1", PAGE="2")

...and it now works. As usual Firefox is more understanding and didn't
present any errors.

Ciao for now,

Richard

That dang IE!!! Glad it works!

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com