[coldbox:4091] best way to use remote proxy in modules?

I have an application which uses CB remoteproxy feature a lot. Now I
likte to use it as a modul. All proxies are in the folder "remote".

As a standalone app the request lets say from a grid component
(jqgrid) is
"/remote/user.cfc?method=getUsers"

Now as module with SES
"/admin/remote/user.cfc?method=getUsers"

that causes an error "The event: admin:remote.user.cfc is not valid
registered event."
What would be the best way to add a modul with remoteproxy and SES?

Daniel

I'm still wondering what ist the best practise with remoteproxies and
modules.

I love the new module feature and to be able to drop a standalone CB
application as a module in another application is IMHO a killer
feature.

So far I could not figure out how to use an exisitng proxy form
standalone application in a module configuration?

I have remote calls in the standalone version like "coldboxproxy.cfc?
method=process&event=user.list"

used a s amodul I have to put the proxy in the root of the parent
application and modify the event modify the event

remote any function doProcess() returnformat="plain" {
    var results = "";
    //process a coldbox request

    results = super.process(argumentCollection=arguments);
    return results;
  }

as "coldboxproxy.cfc?method=process&event=admin:user.list"

sorry, the last post was send to early...

the doProcess function should be:

remote any function doProcess() returnformat="plain" {
                var results = "";
                //process a coldbox request
    if(structKeyExists(arguments,'event')
      arguments.event = 'admin:'&arguments.event =
                results =
super.process(argumentCollection=arguments);
                return results;
        }
thus it becomes process(event=admin:user.list)

which is a hack...

Daniel

Daniel, a few things.

The remote proxies can exist anywhere within the application directory, and named as you se fit. Usually, for best practice I create either a remote folder or api folder and place my remote proxies there. Also, you see I use plural, proxies. Don’t create one single proxy with all the methods on it and then you basically created a God Proxy. No, each proxy is an object and MUST have an identity. Treat it as a real object and organize them by functionality or types just like any other object.

Second, for modules, the proxies can also exist anywhere, the difference is on the way that you internally in the proxies call the process() method. The process() method is the way that you delegate from a proxy into the event model for processing. It takes in 0 or * arguments but one of those arguments must be the event argument which denotes to which event you want to delegate processing to.

The format for event syntax is the following: [module:][package.]handler[.action]
So if I want to delegate to a module called “admin”, to a handler called “users” and an action called “save”. I would have this:

process(event=“admin:users.action”)

Does this seem clear now? Or did I totally miss the question :slight_smile:

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

Excuse me for being unclear.

I understand how to call from a proxy an event in a module with the
pattern
[module:][package.]handler[.action]

My concern is how do I call the proxy from the module views by keeping
the module independent from the parent application.
For my taste to call the proxy from a view inside a module with the
format [module:][package.]handler[.action] notation sounds like
coupling. I would prefer to keep [package.]handler[.action] format in
remote event calls from within views inside a module. Thus I am able
to use the module as standalone application as well. Or the other way
around: I could easily integrate a standalone application as a module
without changing the event calls in the views. Thus an ajax remote
request "doEvent(event='users.list')" doesn't have to be changed when
you use it as standalone application or module.

At the moment I'm thinking of some kind of event preprocessing in an
interceptor. When the application is used as module, the [module:]
prefix gets added automatically to all requests from module views.
Thus "event=users.action" would be transformed to
"event={modulename}:users.action". But I see practical problems, how
should the interceptor know that this event is fired from a view
inside the module and how he knows the name of the module?

Maybe I'm thinking to academic, but I just like to have to module as
independent as possible from the parent application.

Daniel

And you can. You can use the event.getCurrentModule() to determine if you are within a module or not and then use that to build your links. You can also determine your location, whether parent or module by using event.getModuleRoot(). These give you the ability to create what you need whether the module is a standalone application or a module.

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

You need to go to the cfc directly not the ses as you are calling the
remote Cfc.