您的位置:

关于extjsmvc传输数据的信息

本文目录一览:

Extjs mvc 模式下怎么获得后台传过来的数据。请写详细了谢谢了

extjs是一个前台的组件化的框架,在使用extjs组件时比如datagrid,会有一个url的配置参数,运行时自动请求你这个url,只要你后台传递过来的数据正确会自动显示出来

extjs+mvc给Ext表单添加数据,然后以实体的形式返回到后台

js代码:

Ext.define('app.site.projectWindow', {

extend: 'Ext.window.Window',

border: 0,

height:380,

width: 440,

layout: {

type: 'border'

},

title: '新建监测项目',

constrain: true,

modal: true,

initComponent: function() {

var me = this;

var row = me.row;

var required = 'span style="color:red;font-weight:bold" data-qtip="Required"*/span';

Ext.applyIf(me, {

items: [

{

xtype: 'form',

region: 'center',

frame: true,

layout: {

type: 'column'

},

defaults: {

margin:'2 0 0 0',

columnWidth:.9

},

bodyPadding: 10,

title: '',

items: [

{

xtype: 'hiddenfield',

fieldLabel: '监测因子id',

name:'project.id',

value:row==''?'':row.get('id')

},

{

xtype: 'textfield',

fieldLabel: '名称',

name:'project.name',

afterLabelTextTpl : required,

allowBlank : false,

value:row==''?'':row.get('name')

},

{

xtype: 'textfield',

fieldLabel: '编码',

name:'project.code',

value:row==''?'':row.get('code')

},

{

xtype: 'textfield',

fieldLabel: '单位',

afterLabelTextTpl : required,

allowBlank : false,

name:'project.unit',

value:row==''?'':row.get('unit')

},

{

xtype: 'numberfield',

fieldLabel: '最大值',

afterLabelTextTpl : required,

allowBlank : false,

name:'project.maxNum',

value:row==''?'':row.get('maxNum')

},

{

xtype: 'numberfield',

fieldLabel: '最小值',

afterLabelTextTpl : required,

allowBlank : false,

name:'project.minNum',

value:row==''?'':row.get('minNum')

},

{

xtype: 'numberfield',

fieldLabel: '报警值',

afterLabelTextTpl : required,

allowBlank : false,

name:'project.alarmNum',

value:row==''?'':row.get('alarmNum')

},

{

xtype: 'numberfield',

fieldLabel: '小数位',

name:'project.decimal',

value:row==''?'':row.get('decimal')

},

{

xtype: 'textfield',

fieldLabel: '国标No',

name:'project.guobiaoNo',//对象.属性

value:row==''?'':row.get('guobiaoNo')

},

{

xtype: 'textfield',

fieldLabel: '数据Mk',

name:'project.shujuMk',,//对象.属性 value:row==''?'':row.get('shujuMk')

},

{

xtype: 'textareafield',

fieldLabel: '备注',

name:'project.mask',

value:row==''?'':row.get('mask')

}

]

}

],

buttonAlign:'center',

buttons:[{

width : 100,

text : '提交',

iconCls : 'icon-ok',

handler : function(t,e) {

t.setDisabled(true);

var form = me.down('form').getForm();

var url = 'project!savePro.action';

if(row!='')url = "project!update.action";

if (form.isValid()) {

Ext.Ajax.request({

url : url,

params : form.getValues(),

success : function(response) {

var text = Ext.JSON.decode(response.responseText);

if (text.success) {

me.grid.getStore().load();

me.close();

} else {

t.setDisabled(false);

Ext.Msg.alert('提示', '操作失败');

}

}

});

} else {

t.setDisabled(false);

Ext.MessageBox.alert('提示', '请填写正确的信息');

}

}

},{

width : 100,

text : '重置',

iconCls : 'icon-reset',

handler : function(t,e) {

me.down('form').getForm().reset();

}

},

{

width : 100,

text : '退出',

iconCls : 'icon-cancel',

handler : function(t,e) {

me.close();

}

}]

});

me.callParent(arguments);

}

});

java代码:

package com.szusst.action.site;

import java.util.ArrayList;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.Action;

import com.szusst.entity.TBasMoniProject;

import com.szusst.service.BaseService;

public class ProjectAction implements Action{

private BaseService baseService;

private int limit;// 行数

private int start;// 开始行数

private int total;// 总数

private String key;

private ListTBasMoniProject list = new ArrayListTBasMoniProject(0);

private Boolean success;

private TBasMoniProject project = new TBasMoniProject();//这个是需要set方法和get方法--关键

private String proIds;

public String execute() {

int []num = {0};

list = baseService.queryProjects(limit, start, key, num);

total = num[0];

success = true;

return SUCCESS;

}

public String savePro() {

success = baseService.savePro(project);

return SUCCESS;

}

public String delete() {

long num = baseService.deletePro(proIds);

if(num0){

success = true;

}

return SUCCESS;

}

public String update() {

success = baseService.updatePro(project);

return SUCCESS;

}

public int getTotal() {

return total;

}

public ListTBasMoniProject getList() {

return list;

}

public Boolean getSuccess() {

return success;

}

public void setBaseService(BaseService baseService) {

this.baseService = baseService;

}

public void setLimit(int limit) {

this.limit = limit;

}

public void setStart(int start) {

this.start = start;

}

public void setKey(String key) {

this.key = key;

}

@JSON(serialize=false)

public TBasMoniProject getProject() {

return project;

}

public void setProject(TBasMoniProject project) {

this.project = project;

}

public void setProIds(String proIds) {

this.proIds = proIds;

}

}

实体类:

package com.szusst.entity;

import java.util.HashSet;

import java.util.Set;

/**

* TBasMoniProject entity. @author MyEclipse Persistence Tools

*/

public class TBasMoniProject{

// Fields

private Integer id;

private TOthSiteType siteType;

private String name;

private String code;

private String unit;

private Integer decimal;

private String maxNum;

private String minNum;

private String alarmNum;

private String mask;

private String guobiaoNo;

private String shujuMk;

private SetTBasMoniEquipment equips = new HashSetTBasMoniEquipment(0);

public TBasMoniProject() {

}

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getCode() {

return code;

}

public void setCode(String code) {

this.code = code;

}

public String getUnit() {

return unit;

}

public void setUnit(String unit) {

this.unit = unit;

}

public Integer getDecimal() {

return decimal;

}

public void setDecimal(Integer decimal) {

this.decimal = decimal;

}

public TOthSiteType getSiteType() {

return siteType;

}

public void setSiteType(TOthSiteType siteType) {

this.siteType = siteType;

}

public String getMaxNum() {

return maxNum;

}

public void setMaxNum(String maxNum) {

this.maxNum = maxNum;

}

public String getMinNum() {

return minNum;

}

public void setMinNum(String minNum) {

this.minNum = minNum;

}

public String getAlarmNum() {

return alarmNum;

}

public void setAlarmNum(String alarmNum) {

this.alarmNum = alarmNum;

}

public String getMask() {

return mask;

}

public void setMask(String mask) {

this.mask = mask;

}

public String getGuobiaoNo() {

return guobiaoNo;

}

public void setGuobiaoNo(String guobiaoNo) {

this.guobiaoNo = guobiaoNo;

}

public String getShujuMk() {

return shujuMk;

}

public void setShujuMk(String shujuMk) {

this.shujuMk = shujuMk;

}

public SetTBasMoniEquipment getEquips() {

return equips;

}

public void setEquips(SetTBasMoniEquipment equips) {

this.equips = equips;

}

}

配置文件:

action name="project" class="com.szusst.action.site.ProjectAction"

result name="success" type="json"/result

/action

然后就是配置好structs.....基本上就ok 。。。。

extjs+springMVC架构,前台多条记录怎么传递到后台且封装成多个对象

简单说下:1.用Ext.getCmp("id").getValue();等方法获得当前界面中你想传递到后台的值; 2.用formpanel.form.doAction('submit',{ url:'logic.jsp', method:'post', params:, //把需传到后台的数据放在这里。 success : function(form,action){ i

关于extjsmvc传输数据的信息

2022-11-23
关于java学习笔记良葛格的信息

2022-11-11
关于已前的学习笔记java的信息

2022-11-18
关于java对话框的信息

2023-01-04
关于python学习第四次笔记的信息

2022-11-08
关于js定时查询数据库数据库数据的信息

2022-11-24
关于java性能的小笔记(java代码性能分析)

2022-11-12
关于python学习笔记十三的信息

2022-11-19
关于php跨域shang传文件的信息

2022-11-10
htmljs编程笔记(html代码笔记)

本文目录一览: 1、html代码和JS代码有什么区别 2、如何在html中调用js函数 3、JavaScript学习笔记之数组基本操作示例 4、HTML5初学者笔记 5、《web前端笔记7》js字符—

2023-12-08
关于java基础知识笔记1的信息

2022-11-20
关于jfcio的信息

2022-11-28
关于flashphpmysql的信息

2022-11-21
关于javajsptomcatmysql的信息

本文目录一览: 1、如何在服务器上配置JSP,jsp的服务器到底怎么配置啊? 2、jsp 跟tomcat和mysql有什么联系,怎么用?越详细越好!谢谢 3、怎么用jsp连接mysql数据库 4、如何

2023-12-08
java学习笔记(java初学笔记)

2022-11-14
印象笔记记录java学习(Java成长笔记)

2022-11-12
java笔记,尚硅谷java笔记

2022-12-01
js高级程序设计笔记14(js高级程序设计笔记14页)

本文目录一览: 1、JavaScript高级程序设计 该怎么看 2、JavaScript学习笔记之数组基本操作示例 3、JS中有关sort以及return的问题 JavaScript高级程序设计 该怎

2023-12-08
java笔记,大学java笔记

2022-11-28
关于php实现datagrid的信息

2022-11-15