关闭

关闭

封号提示

内容

首页 Extjs如何与数据库交互.doc

Extjs如何与数据库交互.doc

Extjs如何与数据库交互.doc

上传者: zhangpeng2084 2011-12-25 评分1 评论0 下载640 收藏0 阅读量680 暂无简介 简介 举报

简介:本文档为《Extjs如何与数据库交互doc》,可适用于IT书籍领域,主题内容包含一般需要添加一组数据引入一个概念ExtdataReader,这里的Reader功能非常单一只是用来解析数据的到EXTJS支持不同的数据格式也就需要不符等。

一般需要添加一组数据引入一个概念ExtdataReader,这里的Reader功能非常单一只是用来解析数据的到EXTJS支持不同的数据格式也就需要不同的数据解析器。而这个Reader就是承担解析器的作用。、数组形式数据解析(特殊的JSON形式数据因此ArrayReader是JsonReader的子类)varstore=newExtdataStore({        data:"陈治文","男","张妍娜","女",        reader:newExtdataArrayReader({             },ExtdataRecordcreate("name","sex"))        })解析器为ArrayReader分别解析"陈治文","男"和"张妍娜","女"将其转换成ExtdataRecord。、JSON形式数据varstore=newExtdataStore({         data:{name:"陈治文",sex:"男"},{name:"张妍娜",sex:"女"},         reader:newExtdataJsonReader({              },ExtdataRecordcreate("name","sex"))        })           alert(storegetCount())JsonReader分别解析{name:"陈治文",sex:"男"}和{name:"张妍娜",sex:"女"}将这些数据解析成ExtdataRecord类型数据、XML形式数据这里的有个地方比较麻烦首先我们必须得构建一个XMLDocument这样才能形成XML数据我们这里所讲的是ASPServer的XML组织形式varxml=newXML("<table><row><name>陈治文<name><sex>男<sex><row><row><name>张妍娜<name><sex>女<sex><row><table>")这样就是构建一个XML对象通过xmlgetValue()得到xmldocument原型再者我们还有需要引入一个新型概念数据代理ExtdataDataProxy,数据代理的作用就是通过一定的方式来获得数据目前EXTJS提供三种方式获得数据:内存传入、HTTP传入、跨域传入。我这里所讲是内存传入ExtdataMemoryProxyvarstore=newExtdataStore({        proxy:newExtdataMemoryProxy(xmlgetValue()),        reader:newExtdataXmlReader({              record:"row"             },ExtdataRecordcreate("name","sex"))        })           storeon("load",function(store){                  alert(storegetAt()getCount())                  })           storeload() 摘自:陈治文非本人原创ExtJS与JSP连接,把数据写入数据库年月日星期三下午:haha使用ExtJS颇有心得下面的问题本来是我问别人的最后自己搞定了改自一个与PHP的版本。现在有一个ExtJS做的前台注册窗口窗口中有用户和密码两栏一个提交按钮。现在在用户和密码两栏中填入数据之后点提交按钮数据通过EXTJS提交到JSP然后写入数据库。要全部的代码:ExtJS(前台部分):<!首先前台部分使用extjs写一个简单的注册窗口文件名为loginhtml><!DOCTYPEhtmlPUBLIC"WCDTDXHTMLTransitionalEN""http:wwwworgTRxhtmlDTDxhtmltransitionaldtd"><htmlxmlns="http:wwwworgxhtml"><head><metahttpequiv="ContentType"content="texthtmlcharset="><title>extDemo<title><linkrel="stylesheet"type="textcss"href="extresourcescssextallcss"><scripttype="textjavascript"src="extadapterextextbasejs"><script><scripttype="textjavascript"src="extextalljs"><script><head><body><script>ExtonReady(function(){         使用表单提示         ExtQuickTipsinit()         ExtformFieldprototypemsgTarget='side'                                  定义表单         varsimple=newExtFormPanel({                               labelWidth:,                                                       baseCls:'xplain',                               defaults:{width:},                               defaultType:'textfield',默认字段类型                                               定义表单元素                               items:{                                               fieldLabel:'帐户',                                               name:'name',元素名称                                               anchor:'',也可用此定义自适应宽度                                               allowBlank:false,不允许为空                                               blankText:'帐户不能为空'错误提示内容                                       },{                                           inputType:'password',                                               fieldLabel:'密码',                                               anchor:'',                                               name:'pws',                                               allowBlank:false,                                               blankText:'密码不能为空'                                       }                               ,                               buttons:{                                       text:'提交',                                       type:'submit',                                       定义表单提交事件                                       handler:function(){                             if(simpleformisValid()){验证合法后使用加载进度条                                                             ExtMessageBoxshow({                                                                          title:'请稍等',                                                                          msg:'正在加载',                                                                          progressText:'',                                                                          width:,                                                                          progress:true,                                                                          closable:false,                                                                          animEl:'loding'                                                                  })                                                                  控制进度速度                                                                  varf=function(v){                                                                        returnfunction(){                                                                                               vari=v                                                                                               ExtMessageBoxupdateProgress(i,'')                                                                           }                                                                  }                                                                  for(vari=i<i){                                                                               setTimeout(f(i),i*)                                                                  }                                                                                                  提交到服务器操作                                                                 simpleformdoAction('submit',{                                                                        url:'checkjsp',文件路径                                                                        method:'post',提交方法post或get                                                                        params:'',                                                                        提交成功的回调函数                                                                        success:function(form,action){                                                                                       if(actionresultmsg=='ok'){                                                                                               documentlocation='indexhtml'                                                                                               ExtMsgalert('提示窗口','提交已成功!')                                                                                       }else{                                                                                               ExtMsgalert('登陆错误',actionresultmsg)                                                                                       }                                                                        },                                                                        提交失败的回调函数                                                                        failure:function(){                                                                                       ExtMsgalert('错误','服务器出现错误请稍后试!')                                                                        }                                                                 })                                                          }                                                                                                                     }                               },{                                       text:'取消',                                       handler:function(){simpleformreset()}重置表单                               }                       })                                 定义窗体                                  win=newExtWindow({                                               id:'win',                                               title:'注册窗口',                                               layout:'fit',  之前提到的布局方式fit自适应布局                                                                                  width:,                                               height:,                                               plain:true,                       bodyStyle:'padding:px',                                               maximizable:false,禁止最大化                                               closeAction:'close',                                               closable:false,禁止关闭                                               collapsible:true,可折叠                                               plain:true,                                               buttonAlign:'center',                                               items:simple将表单作为窗体元素嵌套布局                                       })                                       winshow()显示窗体                                                                                               })<script><body><html>JSP(后台部分)代码:<!后台部分这里数据库使用的是Access数据库   本文件名为checkjsp><pagelanguage="java"contentType="texthtmlcharset=gb"   pageEncoding="gbk"><pageimport="javasql*,javautil*"><     requestsetCharacterEncoding("gb")     Stringname=requestgetParameter("name")     Stringpws=requestgetParameter("pws")     if(nameequals(pws)){        outprint("{success:true,msg:'ok'}")     }else{        outprint("{success:true,msg:'帐户或密码错误'}")     }          try{     Stringmessage=pws     StringsourceURL="jdbc:odbc:driver={MicrosoftAccessDriver(*mdb)}DBQ=D:accdb"    DataBase是AccessMDB文件的主文件名     try{           ClassforName("sunjdbcodbcJdbcOdbcDriver")           }catch(Exceptione){            eprintStackTrace()        }     Connectionconn=DriverManagergetConnection(sourceURL)把驱动放入连接     Statementstmt=conncreateStatement()创建一个Statement对象来将SQL语句发送到数据库。     stmtexecuteUpdate("INSERTINTOstudentVALUES(""'"name"'"",""'"message"'"")")         stmtclose()     connclose()   }   catch(SQLExceptionsqle){           Systemerrprintln(sqle)   }     >

类似资料

编辑推荐

文化研究导论(复习资料)陆扬.doc

0071628037 Writing Better English.pdf

计算机操作系统.第三版.扫描版pdf.带书签.可复制文字

夏道行,实变函数论与泛函分析(第二版)下册.pdf

金融怪杰3 股市奇才on.pdf

职业精品

精彩专题

中国制造,引领“世界第一”

近十年来,我国制造业持续快速发展,总体规模大幅提升,综合实力不断增强,不仅对国内经济和社会发展做出了重要贡献,而且成为支撑世界经济的重要力量。你绝对想不到,中国制造有这么多“世界第一”

用户评论

0/200
    暂无评论
上传我的资料

精选资料

热门资料排行换一换

  • 学校各周安全教育内容.doc

  • 五年中考三年模拟数学三模.doc

  • 解除劳动合同通知书.doc

  • 无政府状态下的合作.doc

  • 老年人活动方案.doc

  • 房建施工组织设计.doc

  • 奇门符咒.doc

  • 暗夜的穿越者──对《法治及其本土…

  • 浅谈近代中国的革命与改良[训练]…

  • 资料评价:

    / 7
    所需积分:0 立即下载

    意见
    反馈

    返回
    顶部