Coldfusion 返回类型化对象/AMF 远程处理
ColdFusion 中也可能有同样的情况吗? 目前我正在使用 .Net/Fluorine 将对象返回给客户端。 在测试时,我喜欢传递代表 select 语句的字符串和我希望从服务返回的自定义对象。 Fluorine 有一个类 ASObject,您可以为其设置 var 'typeName';效果很好。 我希望这在 Coldfusion 中是可能的。有谁知道是否可以以类似的方式设置返回对象的类型。 这对于大型集合特别有用,因为 Flash 播放器会将它们转换为同名的本地对象,从而节省对集合的交互以将对象转换为特定的自定义对象。
foreach (DataRow row in ds.Tables[0].Rows)
{
ASObject obj = new ASObject();
foreach (DataColumn col in ds.Tables[0].Columns)
{
obj.Add(col.ColumnName, row[col.ColumnName]);
}
obj.TypeName = pObjType;
al.Add(obj);
}
非常感谢,
Is the same possible in ColdFusion?
Currently I am using .Net/Fluorine to return objects to the client.
Whilst in testing I like to pass strings representing the select statement and the custom object I wish to have returned from my service.
Fluorine has a class ASObject to which you can set the var 'typeName'; which works great.
I am hoping that this is possible in Coldfusion. Does anyone know whether you can set the type of the returned object in a similar way.
This is especially helpful with large collections as the flash player will convert them to a local object of the same name thus saving interating over the collection to convert the objects to a particular custom object.
foreach (DataRow row in ds.Tables[0].Rows)
{
ASObject obj = new ASObject();
foreach (DataColumn col in ds.Tables[0].Columns)
{
obj.Add(col.ColumnName, row[col.ColumnName]);
}
obj.TypeName = pObjType;
al.Add(obj);
}
Many thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,它可以工作并且是内置的,因此您不必使用外部服务器端。
ColdFusion 组件 (CFC) 是类的 ColdFusion 版本。
ColdFusion 的 Flash/Flex Remoting Gateway 将自动将 CFC 转换为 ActionScript 对象。
请记住,CF 是基于 Java 的;因此路径和类名区分大小写。我认为 .NET 不是那样的。
CFC 和 ActionScript 对象应以相同的顺序列出所有属性。在AS3中,你可以将它们定义为公共变量;在 CFC 中,您应该使用 cfproperty 标签定义它们。 ActionScript 对象应使用 RemoteClass 元数据标记来指定 CFC 的绝对位置。 CFC 的 cfcomponent 标记应指定别名属性,该属性是 CFC 对象的绝对路径位置。
如果您的服务中的 CFC 方法返回一个对象; cffunction 标记上的返回类型应该是 CFC 对象的绝对路径。
我预计其中很多内容与您使用 .NET 所做的事情类似;只是语法不同。我非常确定您必须在 CFADmin 中启用 Flex / Flash Remoting,然后这些才能起作用。
CF 文档中的某处应该有 CF 到 Flex 数据类型转换表。
Yes, it works and is built right in so you don't have to use an external server side piece.
ColdFusion Components (CFCs) are the ColdFusion version of an Class.
ColdFusion's Flash/Flex Remoting Gateway will do the automatic conversion of CFCs into ActionScript objects.
Remember that CF is Java based; so the paths and class names are case sensitive. I assume .NET is not like that.
The CFC and ActionScript object should list all properties in the same order. In AS3, you can define them as public variables; in the CFC you should define them using the cfproperty tag. The ActionScript Object should use the RemoteClass metadata tag to specify the absolute location of the CFC. The CFC's cfcomponent tag should specify the alias attribute which is the absolute path location of the CFC Object.
If the CFC method in your service returns an object; the return type on your cffunction tag should be the absolute path to the CFC Object.
I would expect a lot of this is similar to what you've been doing with .NET; just with different syntax. I'm pretty sure you have to enable Flex / Flash Remoting in the CFADmin before any of this will work.
There should be a CF to Flex data type conversion chart somewhere in the CF Docs.
您还可以返回一个带有名为“type”的特殊键的结构体,其中包含属性所代表的 AS 类的值,Flex 将填充这些对象。
例如
(请注意,这是“下划线下划线类型下划线下划线”,格式已被删除)
You can also return a struct with a special key called 'type' with the value of the AS class that the properties represent, and Flex will populate those objects.
For example
(note that is 'underscore underscore type underscore underscore', the formatting is bein stripped)