有人能解释一下FW1服务调用是如何工作的吗?当我从下面的手册中读到这一节时。我认为下面的方法应该有效。
请参阅:https://github.com/seancorfield/fw1/wiki/Reference-Manual
服务方法将根据控制器方法执行后请求上下文中的内容传递一个命名参数的集合(即,在前面( )、startItem()和item()之后)。服务方法可以返回结果,该结果由FW/1放置到请求上下文中。默认情况下,FW/ 1.x将(初始)服务方法调用的结果存储在rc.data中。
控制器/比较器
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 );
}
}服务/比较
component {
public any function autocomplete( string table, string column, string term ) {
return "not yet implemented #table# #column# #term#";
}
}下面的视图显示rc.autocomplete =“尚未实现”
视图/可比较/自动完成。
<cfdump var="#variables.rc#" >发布于 2012-11-07 20:57:33
我终于弄明白了这一切是如何结合在一起的。下面的服务调用将立即返回一个值,而在控制器方法完成之前不会调用上面的值。
comp_serv = CreateObject("component","services.comparables");
rc.comparables = comp_serv.autocomplete( "table","colum","term" );https://stackoverflow.com/questions/13130231
复制相似问题