The Event Handlers
The event handlers that you will produce for remote interaction are exactly the same as your other handlers, with the exception that they have a return type and return data back to the caller; our proxies. Then our proxies can strong type the return data elements:
Handler:
1
function getCacheKeys(event,rc,prc){
2
return getCache( rc.cacheProvider ).getKeys();
3
}
4
5
function listUsers(event,rc,prc){
6
prc.data = userService.list();
7
8
if( event.isProxyRequest() ){
9
return prc.data;
10
}
11
12
event.setView("users/listUsers");
13
}
Copied!
Hint The request context has a method called isProxyRequest() which tells the application if the request is coming from a ColdBox proxy.
Proxy:
1
array function getCachekEys(string cacheProvider='default'){
2
arguments.event = "proxy.getCacheKeys";
3
return process(argumentCollection=arguments);
4
}
5
6
string function getUsersJSON(){
7
arguments.event = "proxy.listUsers";
8
return serializeJSON( process(argumentCollection=arguments) );
9
}
Copied!
Copy link