ext form的组件用法,以及提交返回数据的注意事项
来源:互联网 发布:淘宝商城巴拉巴拉 编辑:程序博客网 时间:2024/06/15 14:45
extjs中form的用法,效果图:
上代码:
var form =new Ext.FormPanel({url : 'xxx.do',renderTo :document.body,frame : true,title : '表单',width : 500,x:300,items : [{xtype : 'textfield',//相当于html中<input type="text" />fieldLabel : '姓名',name : 'username',allowBlank : false,value : '',readonly : 'readonly'},{fieldLabel : '密码',//相当于html中<input type="password" />name : 'password',xtype : 'textfield',inputType : 'password',allowBlank : false},{//时间插件fieldLabel : '时间',name : 'released',xtype : 'datefield',format:'Y-m-d'//disabledDays: [0,6]},{//radioxtype:'fieldset',title:'颜色',autoHeight:true,defaultType:'radio',hideLabels: true,items: [{ boxLabel: '彩色', name: 'color', inputValue: '1', checked: true},{ boxLabel: '白色', name: 'color', inputValue: '2' },{ boxLabel: '黑色', name: 'color', inputValue: '3' }]},{//checkboxtitle:'食物',xtype:'fieldset',autoHeight:true,items: [{ boxLabel: '馒头', name: 'food', inputValue: '1',xtype:'checkbox', checked: true},{ boxLabel: '面包', name: 'food', inputValue: '2' ,xtype:'checkbox'},{ boxLabel: '米饭', name: 'food', inputValue: '3' ,xtype:'checkbox'}]},{xtype : 'htmleditor',name : 'description',anchor: '100%'}],buttons : [{text : '确定',handler:function(){//var pass=form.getForm().findField('sex');//alert( pass.getValue());//alert( pass.getGroupValue ( ));form.form.submit({success:function(form,action){alert('succ'+action.response.responseText);//responseText后台返回的全部数据},failure:function(form,action){alert('error'+action.response.responseText);}});}},{text : '取消',handler:function(){alert('取消');}}]});
后台servlet处理提交上来的数据,获取的时候跟正常的html的获取方式是一样的,代码:
String username=request.getParameter("username");String password=request.getParameter("password");String released=request.getParameter("released");String color=request.getParameter("color");String[] food=request.getParameterValues("food");//取多选框的值String description=request.getParameter("description");
后台返回的时候一定要注意,返回的是json格式的字符串,而且一定要有success:true,不然前台的ext定义的回调函数就会走failure的方法,正确的代码如下:
PrintWriter out=response.getWriter();result="{success:true , msg:'form',xxxx:'xxxxx'}";out.write(result);out.close();
0 0
- ext form的组件用法,以及提交返回数据的注意事项
- Ext.form.TextField组件的基本用法
- ext的form提交
- Ext中弹出框的form表单提交和接收返回数据
- ext JS Ext.form.FormPanel 如何显示提交后服务器返回的错误信息?
- Ext.form.FieldSet的用法
- extJS提交form表单数据的方式: Ext.Ajax.request,form.submit,getEl().dom.submit()
- Ext.form.FormPanel 提交数据
- EXT的form表单提交方式总结
- Ext 实现简单的form表单提交
- Extjs Ajax 提交方式 Form.doAction('submit',...)和 Ext.Ajax.request的返回值
- Ext form action 提交返回方式
- 提交form 的时候一小点注意事项
- spring security的ajax提交和json返回数据--兼容form表单提交
- form表单提交返回数据
- go语言form表单提交以及后台如何接收并返回做一个简单的解释
- Ext.form.ComboBox提交始终获得displayField的值-解决
- Extjs form.submit()提交与Ext.Ajax.request的区别
- 手把手教你selenium_搭建环境_软件下载
- 怎样写好简历
- Qt串口通信学习方法
- 增强现实技术:何时能真正应用到航空、医疗领域
- php里include,include_once, require和require_once的区别
- ext form的组件用法,以及提交返回数据的注意事项
- QTP之drag and drop
- eclipse的设置和调优
- ldconfig功能以及常见用法简介
- 第二周作业
- python 字符串处理
- Sim卡的EF文件有何作用?
- 上个月刚融资4000万美元的云端教育软件公司Renaissance Learning今日出售,售价11亿美元
- C++章节一作业