0

有人可以解释 FW1 服务调用是如何工作的吗?当我阅读下面手册中的部分时。我认为以下应该有效。

参见:https ://github.com/seancorfield/fw1/wiki/Reference-Manual

服务方法被传递一组命名参数,基于控制器方法执行后请求上下文中的任何内容(即 before()、startItem() 和 item() 之后)。服务方法可能会返回一个结果,该结果由 FW/1 放入请求上下文中。默认情况下,FW/1 1.x 将(初始)服务方法调用的结果存储在 rc.data 中。

控制器/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 );
}

}

服务/comparables.cfc

component { 
public any function autocomplete( string table, string column, string term ) {      
    return "not yet implemented #table# #column# #term#";
}

}

以下视图显示 rc.autocomplete = "not yet implemented"

意见/可比性/autocomplete.cfm

<cfdump var="#variables.rc#" >
4

1 回答 1

0

我终于能够弄清楚这一切是如何结合在一起的。以下服务调用将立即返回一个值,而在控制器方法完成之前不会调用上述服务调用。

comp_serv = CreateObject("component","services.comparables");
rc.comparables = comp_serv.autocomplete( "table","colum","term" );
于 2012-11-07T20:57:33.940 回答