5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:北京
性别:先生
最后登录:2014-08-29
http://veteran.5d.cn/
www.toswf.com
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/10/13 | Coldfusion读取数据库中的信息,Flex格式化这些信息(二)(制作一个guestbook)
类别(ColdFusion)
|
评论
(0)
|
阅读(402)
|
发表于 15:48
下面要制作的是guestbook的写数据库部分,这次flex需要传递数据给cf,调用as脚本来执行cf端定义的insertData
函数。下面是flex的全部代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
function insertdata(){
sendData.insertData(name.text,title.text,content.text);
}
]]>
</mx:Script>
<mx:WebService wsdl="http://localhost/cf/AddData.cfc?WSDL" id="sendData" showBusyCursor="true">
<mx:operation name="insertData"/>
</mx:WebService>
<mx:Binding source="sendData.insertData.result" destination="sta.text"/>
<mx:HBox width="372">
<mx:Label text="Name:" width="50"/>
<mx:TextInput text="" id="name"/>
</mx:HBox>
<mx:HBox width="372">
<mx:Label text="Title" width="50"/>
<mx:TextInput text="" width="301" id="title"/>
</mx:HBox>
<mx:HBox width="372">
<mx:Label text="Content:" width="50"/>
<mx:TextArea text="" width="300" height="79" id="content"/>
</mx:HBox>
<mx:HBox width="268">
<mx:Button label="Submit" click="insertdata()"></mx:Button>
<mx:Button label="Clear" click="insertdata() "></mx:Button>
<mx:Text text="null" id="sta"></mx:Text>
</mx:HBox>
</mx:Application>
截图:
图片如下:
注意script标签部分的函数------
下面是cf端的函数代码:
<cfcomponent>
<cffunction name="insertData" access="remote" returntype="string">
<cfargument name="myName" type="string" required="yes">
<cfargument name="myTitle" type="string" required="yes">
<cfargument name="myContent" type="string" required="yes">
<cfset Date="#DateFormat(Now(), 'yyyy/mm/dd')#">
<cfquery datasource="mygb">
INSERT INTO mygb(name,title,content,mdate) valueS('#myName#','#myTitle#','#myContent#','#Date#')
</cfquery>
<cfset result="Your comment has been added successfully.">
<cfreturn result>
</cffunction>
</cfcomponent>
0
评论
Comments
日志分类
首页
[185]
Flash
[123]
ColdFusion
[2]
Flex
[2]
FlashMedia
[3]
RIA
[4]
Other
[43]
Python
[0]
Design
[8]