关于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

原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/192926.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
小蓝小蓝
上一篇 2024-12-01 10:31
下一篇 2024-12-01 10:31

相关推荐

  • Python读取CSV数据画散点图

    本文将从以下方面详细阐述Python读取CSV文件并画出散点图的方法: 一、CSV文件介绍 CSV(Comma-Separated Values)即逗号分隔值,是一种存储表格数据的…

    编程 2025-04-29
  • Python中读入csv文件数据的方法用法介绍

    csv是一种常见的数据格式,通常用于存储小型数据集。Python作为一种广泛流行的编程语言,内置了许多操作csv文件的库。本文将从多个方面详细介绍Python读入csv文件的方法。…

    编程 2025-04-29
  • 如何用Python统计列表中各数据的方差和标准差

    本文将从多个方面阐述如何使用Python统计列表中各数据的方差和标准差, 并给出详细的代码示例。 一、什么是方差和标准差 方差是衡量数据变异程度的统计指标,它是每个数据值和该数据值…

    编程 2025-04-29
  • Python多线程读取数据

    本文将详细介绍多线程读取数据在Python中的实现方法以及相关知识点。 一、线程和多线程 线程是操作系统调度的最小单位。单线程程序只有一个线程,按照程序从上到下的顺序逐行执行。而多…

    编程 2025-04-29
  • Python爬取公交数据

    本文将从以下几个方面详细阐述python爬取公交数据的方法: 一、准备工作 1、安装相关库 import requests from bs4 import BeautifulSou…

    编程 2025-04-29
  • Python两张表数据匹配

    本篇文章将详细阐述如何使用Python将两张表格中的数据匹配。以下是具体的解决方法。 一、数据匹配的概念 在生活和工作中,我们常常需要对多组数据进行比对和匹配。在数据量较小的情况下…

    编程 2025-04-29
  • Python数据标准差标准化

    本文将为大家详细讲述Python中的数据标准差标准化,以及涉及到的相关知识。 一、什么是数据标准差标准化 数据标准差标准化是数据处理中的一种方法,通过对数据进行标准差标准化可以将不…

    编程 2025-04-29
  • 如何使用Python读取CSV数据

    在数据分析、数据挖掘和机器学习等领域,CSV文件是一种非常常见的文件格式。Python作为一种广泛使用的编程语言,也提供了方便易用的CSV读取库。本文将介绍如何使用Python读取…

    编程 2025-04-29
  • Python根据表格数据生成折线图

    本文将介绍如何使用Python根据表格数据生成折线图。折线图是一种常见的数据可视化图表形式,可以用来展示数据的趋势和变化。Python是一种流行的编程语言,其强大的数据分析和可视化…

    编程 2025-04-29
  • Python如何打乱数据集

    本文将从多个方面详细阐述Python打乱数据集的方法。 一、shuffle函数原理 shuffle函数是Python中的一个内置函数,主要作用是将一个可迭代对象的元素随机排序。 在…

    编程 2025-04-29

发表回复

登录后才能评论