- 浏览: 176691 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
LoveJava123:
第二个名字改一下就ok了。但是缺点若是中文的就好了。
[分享]JFreeChart API文档(chm格式) -
wanxiaotao12:
好文章, spring源码可以深入研究
spring BeanWrapperImpl 单个 或 多个 property 赋值 -
gaoyibin:
为什么你这边下载的curl.exe不能打开呢?双击完后就瞬间消 ...
抛个砖头->[curl---javaeye---api]-----初体验 -
步青龙:
好文章 赞一个
HashMap简析之-HashCode冲突的解决 -
weng:
并不是解释不准确,是翻译不行
读《java编程思想》final 参数的测试
转载自:http://www.cnblogs.com/Missing1984/archive/2008/09/26/1299684.html
写的比较详细;尤其是客户端js代码.参考了
----------------------------------------------------------------------
框架是 Extjs+Structs2+Spring+Hibernate 直接调用action获取数据和保存
页面JS代码如下
JsonReader和Dataproxy定义
2张表 一张Userinfo 一张Departmentinfo Departmentinfo 用来填充表单的ComboBox
var Userreader = new Ext.data.JsonReader({ totalProperty: "totalSize", root: "data" }, Ext.data.Record.create([{ name: "UserID", type: "string" }, { name: "UserName", type: "string" }, { name: "UserPassword", type: "string" }, { name: "RoleList", type: "string" }, { name: "FuncList", type: "string" }, { name: "Sex", type: "string" }, { name: "WenHua", type: "string" }, { name: "Age", type: "int" }, { name: "Email", type: "string" }, { name: "Telephone", type: "string" }, { name: "Cellphone", type: "string" }, { name: "ShortName", type: "string" }, { name: "DepID", type: "int" }])); var Deptreader = new Ext.data.JsonReader({ totalProperty: "totalSize", root: "data" }, Ext.data.Record.create([{ name: "DepID", type: "int" }, { name: "DepCode", type: "string" }, { name: "DepName", type: "string" }, { name: "Comment", type: "string" }])); var Usercolumns = [{ "header": "UserID", "dataIndex": "UserID", "sortable": "true", "id": "UserID" }, { "header": "UserName", "dataIndex": "UserName", "sortable": "true", "id": "UserName" }, { "header": "UserPassword", "dataIndex": "UserPassword", "sortable": "true", "id": "UserPassword" }, { "header": "RoleList", "dataIndex": "RoleList", "sortable": "true", "id": "RoleList" }, { "header": "FuncList", "dataIndex": "FuncList", "sortable": "true", "id": "FuncList" }]; var Userproxy = new Ext.data.HttpProxy({ url: 'GetUserList.action' }); var Userstore = new Ext.data.Store({ proxy: Userproxy, reader: Userreader }); var Deptproxy = new Ext.data.HttpProxy({ url: 'GetDeptList.action' }); var Deptstore = new Ext.data.Store({ proxy: Deptproxy, reader: Deptreader });
GridPanel
var UserMgrPn = new Ext.grid.GridPanel({ title: '用户管理', closable: true, store: Userstore, columns: Usercolumns, tbar: [{ pressed: true, text: 'Add', handler: doAddUser }, //加上这句,后面的就显示到右边去了 { pressed: true, text: "Edit", handler: doEditUser }, { pressed: true, text: "Delete", handler: doDelUser }] });
增删改事件,试验代码
var doAddUser = function() { var simpleForm = new Ext.FormPanel({ labelWidth: 75, // label settings here cascade unless overridden frame: true, title: 'User Info', bodyStyle: 'padding:5px 5px 0', width: 350, defaults: { width: 230 }, defaultType: 'textfield', items: [{ fieldLabel: 'UserID', name: 'UserID' }, { fieldLabel: 'UserName', name: 'UserName' }, { fieldLabel: 'UserPassword', name: 'UserPassword' }, { fieldLabel: 'RoleList', name: 'RoleList' }, { fieldLabel: 'FuncList', name: 'FuncList' }, { fieldLabel: 'Sex', name: 'Sex' }, new Ext.form.ComboBox({ fieldLabel: 'Department', hiddenName: 'DepID', store: Deptstore, valueField: 'DepID', displayField: 'DepName', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText: 'Select a department', selectOnFocus: true })], buttons: [{ text: 'Save', handler: function() { if (simpleForm.form.isValid()) { simpleForm.form.doAction('submit', { url: 'EditUserSave.action?action=add', method: 'post', params: '', success: function(form, action) { Ext.Msg.alert('success', action.result.info); Userstore.load(); newFormWin.hide(); }, failure: function() { Ext.Msg.alert('fail', 'notice'); } }); } } }, { text: 'Cancel' }] }); var myFormWin = function() { // create the window on the first click and reuse on subsequent // clicks newFormWin = new Ext.Window({ layout: 'fit', width: 400, height: 300, plain: true, title: '', items: simpleForm }); newFormWin.show('New1'); }; myFormWin(); Deptstore.load(); }; var doEditUser = function() { var simpleForm = new Ext.FormPanel({ labelWidth: 75, // label settings here cascade unless overridden frame: true, title: 'User Info', bodyStyle: 'padding:5px 5px 0', width: 350, reader: Userreader, defaults: { width: 230 }, defaultType: 'textfield', items: [{ fieldLabel: 'UserID', name: 'UserID' }, { fieldLabel: 'UserName', name: 'UserName' }, { fieldLabel: 'UserPassword', name: 'UserPassword' }, { fieldLabel: 'RoleList', name: 'RoleList' }, { fieldLabel: 'FuncList', name: 'FuncList' }, { fieldLabel: 'Sex', name: 'Sex' }, new Ext.form.ComboBox({ fieldLabel: 'Department', hiddenName: 'DepID', store: Deptstore, valueField: 'DepID', displayField: 'DepName', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText: 'Select a department', selectOnFocus: true })], buttons: [{ text: 'Save', handler: function() { if (simpleForm.form.isValid()) { simpleForm.form.doAction('submit', { url: 'EditUserSave.action?action=edit', method: 'post', params: '', success: function(form, action) { Ext.Msg.alert('success', action.result.info); Userstore.load(); newFormWin.hide(); }, failure: function() { Ext.Msg.alert('fail', 'notice'); } }); } } }, { text: 'Cancel' }] }); var myFormWin = function() { // create the window on the first click and reuse on subsequent // clicks newFormWin = new Ext.Window({ layout: 'fit', width: 400, height: 300, plain: true, title: '', items: simpleForm }); newFormWin.show('New1'); }; var _record = UserMgrPn.getSelectionModel().getSelected(); if (!_record) { Ext.Msg.alert('修改操作', '请选择要修改的一项!'); } else { myFormWin(); Deptstore.load(); simpleForm.form.load({ url: 'EditUserLoad.action?UserID=' + _record.get('UserID'), waitMsg: '正在载入数据', failure: function(form, action) { Ext.Msg.alert('编辑', '载入失败'); } }); } }; var doDelUser = function() { var _record = UserMgrPn.getSelectionModel().getSelected(); if (!_record) { Ext.Msg.alert('删除操作', '请选择要删除的一项!'); } else { Ext.Msg.confirm('确认', '真的要删除吗?', function(btn) { if (btn == 'yes') { Ext.Ajax.request({ url: 'EditUserSave.action?action=del&UserID=' + _record.get('UserID'), success: function(result) { Ext.Msg.alert('Result', '删除成功!'); Userstore.load(); } }); } }); } };
后台Java代码如下
UserService
public class UserService extends BaseAction { /** * */ private static final long serialVersionUID = 1L; private String UserID; private String UserName; private String UserPassword; private String RoleList; private String FuncList; private Integer sex; private String wenHua; private Integer age; private String shortName; private String email; private String telphone; private String cellphone; private Integer DepID; private UserinfoDAO userdao; @SuppressWarnings("unchecked") public String GetUserList() throws IOException { Iterator ir = userdao.findAll().iterator(); List list = new ArrayList(); while (ir.hasNext()) { Userinfo user = (Userinfo) ir.next(); Map<String, Object> row = new HashMap<String, Object>(); row.put("UserID", user.getUserId()); row.put("UserName", user.getUserName()); row.put("UserPassword", user.getUserPassword()); row.put("RoleList", user.getRoleList()); row.put("FuncList", user.getFuncList()); row.put("Sex", user.getSex()); row.put("WenHua", user.getWenHua()); row.put("Age", user.getAge()); row.put("ShortName", user.getShortName()); row.put("Email", user.getEmail()); row.put("Telphone", user.getTelphone()); row.put("CellPhone", user.getCellphone()); list.add(row); } HashMap map = new HashMap(); map.put("totalSize", list.size()); map.put("data", list); JSONObject jSon = new JSONObject(map); getResponse().setContentType("text/json; charset=utf-8"); getResponse().getWriter().write(jSon.toString()); System.out.println(jSon.toString()); return null; } public String GetOneUser() throws IOException { String userID = getRequest().getParameter("UserID"); Userinfo user = userdao.findById(userID); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map<String, Object> row = new HashMap<String, Object>(); row.put("UserID", user.getUserId()); row.put("UserName", user.getUserName()); row.put("UserPassword", user.getUserPassword()); row.put("RoleList", user.getRoleList()); row.put("FuncList", user.getFuncList()); row.put("Sex", user.getSex()); row.put("WenHua", user.getWenHua()); row.put("Age", user.getAge()); row.put("ShortName", user.getShortName()); row.put("Email", user.getEmail()); row.put("Telphone", user.getTelphone()); row.put("CellPhone", user.getCellphone()); row.put("DepID", user.getDeptID()); list.add(row); HashMap<String, Object> map = new HashMap<String, Object>(); map.put("totalSize", list.size()); map.put("data", list); JSONObject jSon = new JSONObject(map); getResponse().setContentType("text/json; charset=utf-8"); getResponse().getWriter().write(jSon.toString()); System.out.println(jSon.toString()); return null; } public String SaveUser() throws IOException { if (getRequest().getParameter("action").equals("edit")) { Userinfo edituser = userdao.findById(UserID); edituser.setUserId(UserID); edituser.setUserName(UserName); edituser.setUserPassword(UserPassword); edituser.setRoleList(RoleList); edituser.setFuncList(FuncList); edituser.setDeptID(DepID); userdao.getHibernateTemplate().update(edituser); getResponse().getWriter().write("{success:true,info:'success'}"); } else if (getRequest().getParameter("action").equals("add")) { Userinfo edituser = new Userinfo(); edituser.setUserId(UserID); edituser.setUserName(UserName); edituser.setUserPassword(UserPassword); edituser.setRoleList(RoleList); edituser.setFuncList(FuncList); edituser.setDeptID(DepID); userdao.getHibernateTemplate().save(edituser); getResponse().getWriter().write("{success:true,info:'success'}"); } else if (getRequest().getParameter("action").equals("del")) { String userID = getRequest().getParameter("UserID"); Userinfo deluser = userdao.findById(userID); userdao.delete(deluser); getResponse().getWriter().write("{success:true,info:'success'}"); } return null; } public UserinfoDAO getUserdao() { return userdao; } public void setUserdao(UserinfoDAO userdao) { this.userdao = userdao; } public Integer getSex() { return sex; } public void setSex(Integer sex) { this.sex = sex; } public String getWenHua() { return wenHua; } public void setWenHua(String wenHua) { this.wenHua = wenHua; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getShortName() { return shortName; } public void setShortName(String shortName) { this.shortName = shortName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getTelphone() { return telphone; } public void setTelphone(String telphone) { this.telphone = telphone; } public String getCellphone() { return cellphone; } public void setCellphone(String cellphone) { this.cellphone = cellphone; } public String getUserID() { return UserID; } public void setUserID(String userID) { UserID = userID; } public String getUserName() { return UserName; } public void setUserName(String userName) { UserName = userName; } public String getUserPassword() { return UserPassword; } public void setUserPassword(String userPassword) { UserPassword = userPassword; } public String getRoleList() { return RoleList; } public void setRoleList(String roleList) { RoleList = roleList; } public String getFuncList() { return FuncList; } public void setFuncList(String funcList) { FuncList = funcList; } public Integer getDepID() { return DepID; } public void setDepID(Integer depID) { DepID = depID; } }
Department
package com.newsoft.struts.action; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import com.newsoft.superOA.PO.*; import com.newsoft.superOA.Util.JSONObject; public class DeptService extends BaseAction { private Integer depId; private String depCode; private String depName; private String comment; private DepartmentinfoDAO depdao; public String GetDeptList() throws IOException { Iterator ir = depdao.findAll().iterator(); List list = new ArrayList(); while (ir.hasNext()) { Departmentinfo dept = (Departmentinfo) ir.next(); Map<String, Object> row = new HashMap<String, Object>(); row.put("DepID", dept.getDepId()); row.put("DepCode", dept.getDepCode()); row.put("DepName",dept.getDepName()); row.put("Comment", dept.getComment()); list.add(row); } HashMap map = new HashMap(); map.put("totalSize", list.size()); map.put("data", list); JSONObject jSon = new JSONObject(map); getResponse().setContentType("text/json; charset=utf-8"); getResponse().getWriter().write(jSon.toString()); System.out.println(jSon.toString()); return null; } public Integer getDepId() { return depId; } public void setDepId(Integer depId) { this.depId = depId; } public String getDepCode() { return depCode; } public void setDepCode(String depCode) { this.depCode = depCode; } public String getDepName() { return depName; } public void setDepName(String depName) { this.depName = depName; } public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } public DepartmentinfoDAO getDepdao() { return depdao; } public void setDepdao(DepartmentinfoDAO depdao) { this.depdao = depdao; } }
相关推荐
EXT.form组件是EXT JS库中用于构建表单界面的核心组件集合。这些组件提供了一系列丰富的控件,用于创建具有不同功能的交互式表单。在EXT JS中,表单组件不仅包含基本的输入字段,还支持复杂的输入类型和验证机制。 ...
### Ext.form表单中各种属性应用详解 #### 1. Ext.form.NumberField **Ext.form.NumberField** 是 **Ext.form.TextField** 的一个扩展,它专为处理数字输入而设计,提供了一系列与数值相关的配置选项。 - **...
Ext grid中渲染进度条,超帅 源码-----下载不扣分,回帖加1分,欢迎下载,童叟无欺。Ext grid中渲染进度条,超帅 源码-----下载不扣分,回帖加1分,欢迎下载,童叟无欺。Ext grid中渲染进度条,超帅 源码-----下载不扣分...
在"Ext.NET后台分页增删改"这个主题中,我们将探讨如何利用Ext.NET实现数据库后台分页、树形视图操作以及Grid面板的CRUD(创建、读取、更新和删除)功能。 首先,让我们深入了解一下后台分页。在Ext.NET中,为了...
在IT领域,特别是Web开发中,Ext Grid是一个广泛使用的组件,用于展示和管理大量数据。它提供了丰富的功能,包括排序、筛选、分页等,使得数据的交互和操作变得非常便捷。当我们需要将Ext Grid中的数据导出为Excel...
EXTGRID是EXT JS库中的一个核心组件,它在Web应用中用于展示数据并提供交互功能。EXT JS是一个基于JavaScript的富客户端框架,用于构建复杂的、数据驱动的Web应用程序。EXTGRID以其强大的数据网格功能,提供了丰富的...
extgrid 是一款jquery上的gird插件 界面风格采用了类似easyui extjs 界面风格样式 可通过css修改自己想要的样式 extgrid具有列大小 位置改变 排序 分组 分页 工具栏 扩展行 rowNumber 多选列 编辑列 行列锁 ajax...
接下来 在mysql里建立 数据库位ext的库 再去项目中 src/META-INF/persistence.xml的配置文件里吧<!-- <property name="hibernate.hbm2ddl.auto" value="update" /> -->这句话的注释去掉 好了 部署项目到tomcat上 ...
总的来说,这个JSP实现的EXT Grid导出Excel例子是一个实用且常见的Web开发需求,它涉及到EXT JS的使用、AJAX通信、服务器端处理以及文件下载等多个技术点。通过这个例子,开发者可以学习到如何将前端的动态数据有效...
本文将深入探讨如何在Ext Grid中实现增删改查(CRUD)操作,这些操作是任何数据管理应用的基础。 首先,我们需要了解`Ext.grid.Panel`,它是Ext JS中的主要表格组件。这个组件可以显示大量数据,并提供了分页、排序...
以上就是关于"ext2.0 树的增删改操作"及其相关知识的详细说明。掌握这些内容,将有助于你在构建Web应用时更熟练地使用树形控件,并且能够根据需求进行定制化开发。同时,了解下拉树的实现,可以使你的界面更加友好,...
### EXT中文手册 Grid Form #### EXT简介 EXT是一款强大的JavaScript框架,主要用于开发Web应用程序的前端界面。它提供了丰富的用户界面组件、数据管理功能以及与服务器端进行交互的能力。本手册旨在帮助开发者...
在EXT(Ext JS)框架中,EXT Grid是一个强大的数据展示组件,它允许用户以表格的形式显示大量数据。在实际业务场景中,有时我们需要将EXT Grid中的数据导出为Excel文件,以便于分析、存储或共享。这个过程涉及到EXT ...
在本示例中,"EXT dojochina文本框示例Ext.form.TextField.rar"是一个压缩包,包含了EXT框架中关于`Ext.form.TextField`组件的示例代码。 `Ext.form.TextField`是EXT框架中的一个核心组件,用于创建基本的输入字段...
在“EXT form小例子”中,我们将探讨EXTJS Form组件的基础用法,包括客户端验证和对`Ext.form.Vtype`的扩展。 1. EXTJS Form组件基础: - 表单创建:EXTJS中的表单通常通过`Ext.create`方法创建,如`Ext.create('...
在EXT JS框架中,Grid组件是一种非常常用的展示数据表格的方式,它提供了丰富的功能和灵活性。在某些场景下,用户可能需要合并行或列以更好地组织和呈现数据,例如在显示汇总信息或者创建复杂的报告时。"ext grid ...
在这个例子中,我们创建了一个简单的EXT Grid,包含了两个字段(姓名和年龄),并且这两个字段都是可编辑的。数据源是从数组中加载的,但也可以通过修改`store`配置来连接到服务器获取数据。 EXT Grid还可以配合...
在IT领域,尤其是在Web开发中,"ext grid json分页显示"是一个常见的需求,它涉及到前端数据展示和后端数据交互的关键技术。本例中提到的解决方案是利用DWR(Direct Web Remoting)和EXT.js库来实现。下面将详细阐述...
在"增删改"操作中,EXTJS的Grid Panel组件可以用于显示数据,并通过Editor Grid插件实现对数据的编辑。增、删、改操作通常通过EXTJS的API与后台服务器进行交互,例如使用Store对象的`add()`, `remove()`, `update()`...
在EXT JS框架中,"ext grid tree 应用"是一个常见的功能组合,它结合了Grid面板和Tree面板的优势,用于展示复杂的数据结构。Grid通常用于显示二维表格数据,而Tree则用于展示层次化的数据。在这个例子中,开发者通过...