Can someone explain how the FW1 service call works? As I read the section from the manual below. I thought the following should work.
See: https://github.com/seancorfield/fw1/wiki/Reference-Manual
A service method is passed a collection of named arguments, based on whatever is in the request context after the controller methods have executed (i.e., after before(), startItem() and item() ). A service method may return a result, which is placed into the request context by FW/1. By default, FW/1 1.x stores the result of the (initial) service method call in rc.data.
controller/comparables.cfc
component {
public any function init( fw ) {
variables.fw = fw;
return this;
}
public void function autocomplete( rc ) {
// queue up a specific service (comparables.autocomplete) with named result (autocomplete)
var args = StructNew();
StructInsert( args, "table", "The Table" );
StructInsert( args, "column", "The Column" );
variables.fw.service( 'comparables.autocomplete', 'autocomplete', args );
}
}
service/comparables.cfc
component {
public any function autocomplete( string table, string column, string term ) {
return "not yet implemented #table# #column# #term#";
}
}
The following view displays rc.autocomplete = "not yet implemented"
views/comparables/autocomplete.cfm
<cfdump var="#variables.rc#" >
I was finally able figure out how it all fits together. The following service call would return a value immediately whereas the above would not be called until the controller method has finished.
comp_serv = CreateObject("component","services.comparables");
rc.comparables = comp_serv.autocomplete( "table","colum","term" );