- 浏览: 236830 次
文章分类
最新评论
-
xryy001:
...
AES加密时抛出java.security.InvalidKeyException: Illegal key size or default parameter -
springdata_springmvc:
bootstrap demo实例教程源代码下载:http:// ...
Bootstrap css修正 -
2047699523:
bootstrap demo实例教程源代码下载:http:// ...
Bootstrap table -
andinyg:
因开发使用的jdk7,其他版本不能解决问题,找了下
jdk7下 ...
AES加密时抛出java.security.InvalidKeyException: Illegal key size or default parameter -
zouzaibianyuan:
...
Listener Servlet
本人学习ext已有一段时间,将我的学习项目贴出来供大家参考
主程序参考ext官方网站的ext的window范例
main.jsp
windows.js
familyMember.js
incomeDaily.js
dwrproxy.js
主程序参考ext官方网站的ext的window范例
main.jsp
<%@ page contentType="text/html; charset=utf-8"%> <%@ page import="org.acegisecurity.context.SecurityContext, org.acegisecurity.userdetails.UserDetails" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>House Charge Expenses System</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="utf-8" /> <meta content="all" name="robots" /> <meta name="author" content="ark"/> <meta name="copyright" content="ark" /> <meta name="description" content="just for testing" /> <meta name="keywords" content="family,finance,study" /> <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/ajaxlib/ext/resources/css/ext-all.css" /> <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/ajaxlib/mylib/ext-patch.css" /> <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/windows.css" /> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/ext/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/ext/ext-all-debug.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/ext/ext-lang-zh_CN.js"></script> <!--buffalo--> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/buffalo/prototype.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/buffalo/buffalo.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/mylib/buffaloext.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/mylib/dwrproxy.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/mylib/ext-lang-zh.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/dwr/interface/houseChargeService.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/dwr/engine.js"></script> <script language="javascript"> dwr.engine.setAsync(false);//同步 var ContextPath="<%=request.getContextPath() %>" var END_POINT="<%=request.getContextPath() %>/bfapp"; var buffalo = new Buffalo(END_POINT,false); </script> <script type="text/javascript" src="<%=request.getContextPath() %>/ajaxlib/mylib/buffaloext.js"></script> <script type="text/javascript" src="desktop.js"></script> <script type="text/javascript" src="windows.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/steady/chargeItem.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/steady/incomeItem.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/steady/familyMember.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/steady/bankAccount.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/daily/incomeDaily.js"></script> </head> <body> <div id="x-taskbar"> <div id="title-bar">House Charge Expenses System</div> <div id="logname">用户名:<strong class="username"> <% SecurityContext context=(SecurityContext)request.getSession().getAttribute("ACEGI_SECURITY_CONTEXT"); UserDetails userDetails=(UserDetails)context.getAuthentication().getPrincipal(); out.print(userDetails.getUsername()); %> </strong> | <a href="<%=request.getContextPath() %>/logout.html">登出</a> </div> <div id="x-launcher-wrap"><div id="x-launcher-inner"><div id="x-launcher-left"><div id="x-launcher-right"><div id="x-launcher-center"><div id="x-launcher"></div><div id="x-info"><ext:user-name /></div></div></div></div></div></div> </div> <div id="x-desktop"> </div> <div id="x-windows"> <div id="x-winlist"><div id="spacer"></div></div> <div class="x-clear"></div> </div> </body> </html>
windows.js
Myapp = new Ext.app.App({ init :function(){ Ext.QuickTips.init(); }, getModules : function(){ return [ new chargeItemWindow(), new incomeItemWindow(), new familyMemberWindow(), new bankAccountWindow(), new incomeDailyWindow(), ]; } });
familyMember.js
familyMemberWindow = Ext.extend(Ext.app.Module, { init : function(){ this.launcher = { text: '家庭成员', iconCls:'icon-grid', handler : this.createWindow, scope: this } }, createWindow : function(){ var desktop = this.app.getDesktop(); var cm = new Ext.grid.ColumnModel([{ header: '姓名', dataIndex: 'name', width: 220, editor: new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank: false})) }]); // by default columns are sortable cm.defaultSortable = true; var FamilyMember = Ext.data.Record.create([ {name:'id',type:'int',mapping:'id'}, {name: 'name',type:'string',mapping: 'name'} ]); var ds = new Ext.data.Store({ proxy: new Buffalo.Ext.DataProxy(buffalo,"houseChargeService.getAllFamilyMember",[]), reader: new Ext.data.ArrayReader({id: 'id'}, FamilyMember), // turn off remote sorting remoteSort: false }); var gridPanel = new Ext.grid.EditorGridPanel({ store: ds, cm: cm, selModel: new Ext.grid.CellSelectionModel(), enableColLock:false, buttonAlign:'top', tbar:[{ text: '新增', handler :doAdd },{ text: '保存', handler : doSave },{ text: '删除', handler : doDel }] }); var win = desktop.getWindow('familyMember-win'); if(!win){ win = desktop.createWindow({ id: 'familyMember-win', title:'家庭成员', width:740, height:460, x:10, y:10, iconCls: 'icon-grid', shim:false, animCollapse:false, constrainHeader:true, layout: 'fit', items: gridPanel }); } ds.load(); win.show(); function doAdd() { var p = new FamilyMember({ id:-1, name:'' }); gridPanel.stopEditing(); var yetCount=ds.getCount(); ds.insert(yetCount, p); //标示cell已修改过 ds.getAt(yetCount).set("name",'未命名'); gridPanel.startEditing(yetCount, 0); } function doSave() { var eds=ds.getModifiedRecords().slice(0); for(var i = 0;i<eds.length;i++){ record =eds[i]; if (record.get("id")==-1) { buffalo.remoteCall("houseChargeService.createFamilyMember",[record.get("name")],function(reply) { var sucess = reply.getResult(); if (sucess==1) { alert("重复姓名!"); } else { if (sucess!=0) { alert("保存失败!"); } else { record.commit(); } } }); } else { buffalo.remoteCall("houseChargeService.updateFamilyMember",[record.get("id"),record.get("name")],function(reply) { var sucess = reply.getResult(); if (sucess==1) { alert("重复姓名!"); } else { if (sucess!=0) { alert("保存失败!"); } else { record.commit(); } } }); } } } function doDel(){ if(gridPanel.selModel.hasSelection()){ Ext.MessageBox.confirm('Message', '确定删除吗?', doDelDetail); } else { Ext.MessageBox.alert('Error', '请选中一行!'); } } function doDelDetail(btn) { if (btn == 'yes') { var record = ds.getAt(gridPanel.selModel.getSelectedCell()[0]); if (record.get("id")==-1) { ds.remove(record); } else { buffalo.remoteCall("houseChargeService.deleteFamilyMember",[record.get("id")],function(reply) { var sucess = reply.getResult(); if (sucess!=0) { alert(" 删除失败!"); } else { ds.remove(record); } }); } } } } });
incomeDaily.js
incomeDailyWindow = Ext.extend(Ext.app.Module, { init : function(){ this.launcher = { text: '收入日记录', iconCls:'icon-grid', handler : this.createWindow, scope: this } }, createWindow : function(){ var desktop = this.app.getDesktop(); Ext.QuickTips.init(); Ext.form.Field.prototype.msgTarget = 'side'; var cm = new Ext.grid.ColumnModel([ { header: "收入项目", sortable: true, dataIndex: 'incomeItem_name', width: 100 },{ header: "日期", dataIndex: 'date', width:60, renderer:Ext.util.Format.dateRenderer('Y/m/d') },{ header: "金额", dataIndex: 'amount', align: 'right', width: 100 },{ header: "家庭成员", dataIndex: 'familyMember_name', width: 80 },{ header: "银行", dataIndex: 'bankAccount_bank', width: 120 },{ header: "帐号", dataIndex: 'bankAccount_accountNo', width: 120 },{ header:"备注", dataIndex: 'remark', width: 80 }]); // by default columns are sortable cm.defaultSortable = true; var IncomeDaily = Ext.data.Record.create([ {name:'id',type:'int',mapping:'id'}, {name: 'incomeItem_name', type: 'string',mapping:'incomeItem.name'}, {name: 'date', type: 'date',dateFormat: 'Y/m/d',mapping:'date'}, {name: 'amount', type: 'float',mapping:'amount'}, {name: 'familyMember_name', type: 'string',mapping:'familyMember.name'}, {name: 'bankAccount_bank', type: 'string',mapping:'bankAccount.bank'}, {name: 'bankAccount_accountNo', type: 'string',mapping:'bankAccount.accountNo'}, {name: 'remark', type: 'string',mapping:'remark'} ]); var ds = new Ext.data.Store({ proxy: new Ext.data.DWRProxy(houseChargeService.findIncomeDaily), reader: new Ext.data.JsonReader({totalProperty:'total',root:'list',id:'id'},IncomeDaily), remoteSort: false, }); var gridPanel = new Ext.grid.EditorGridPanel({ ds:ds, cm: cm, sm: new Ext.grid.RowSelectionModel({singleSelect:true}), enableColLock:false, autoSizeColumns: true, buttonAlign:'top', tbar:[{ text: '新增', handler :doAdd },{ text: '查询', handler : doQuery },{ text: '删除', handler : doDel }], bbar:new Ext.PagingToolbar({ pageSize: 2, store: ds, displayInfo: true }) }); var win = desktop.getWindow('incomeDaily-win'); if(!win){ win = desktop.createWindow({ id: 'incomeDaily-win', title:'收入日记录', width:740, height:460, x:10, y:10, iconCls: 'icon-grid', shim:false, animCollapse:false, constrainHeader:true, layout: 'fit', items: gridPanel }); } win.show(); function doAdd() { var allIncomeItem=[]; buffalo.remoteCall("houseChargeService.findRootIncomeItem",[], function(reply) { getChild(reply.getResult()); function getChild(parent) { if (parent.children.lengt==0) { return 0; } for(var i=0; i<parent.children.length; i++) { allIncomeItem.push([parent.children[i].id,parent.children[i].name]); getChild(parent.children[i]); } } }); var allFamilyMember=[]; buffalo.remoteCall("houseChargeService.getAllFamilyMember",[],function(reply) { var list = reply.getResult(); for(var i=0; i<list.length; i++) { allFamilyMember.push([list[i].id,list[i].name]); } }); var allBankAccount=[]; buffalo.remoteCall("houseChargeService.getAllBankAccount",[],function(reply) { var list = reply.getResult(); for(var i=0; i<list.length; i++) { if (list[i].bank=="现金") { allBankAccount.push([list[i].id,list[i].bank]); } else { allBankAccount.push([list[i].id,list[i].bank+" "+list[i].accountNo+" "+list[i].cardNo]); } } }); var addForm = new Ext.FormPanel({ onSubmit: Ext.emptyFn, submit: function() { this.getEl().dom.submit(); }, labelWidth: 75, // label settings here cascade unless overridden frame:true, title: '', //bodyStyle:'padding:5px 5px 0', ark bodyStyle:'padding: 0', width: 350, labelSeparator:'', items: [{ xtype:'combo', fieldLabel: '家庭成员', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: allFamilyMember }), editable: false, hiddenName:'familyMember_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择家庭成员', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true },{ xtype:'datefield', fieldLabel: '日期', name: 'date', width: 100, allowBlank: false, format:'Y/m/d' }, { xtype:'numberfield', fieldLabel: '金额', name: 'amount', width: 100, allowBlank: false, allowNegative: false, minValue: 0 },{ xtype:'combo', fieldLabel: '账户', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: allBankAccount }), editable: false, hiddenName:'bankAccount_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择账户', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true },{ xtype:'combo', fieldLabel: '收入项目', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: allIncomeItem }), editable: false, hiddenName:'incomeItem_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择收入项目', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true },{ xtype:'textfield', fieldLabel: '备注', name: 'remark', width:300 } ], buttons: [{ text: '保存', handler:function(){ if(addForm.form.isValid()){ var my=addForm.form.getValues(); buffalo.remoteCall("houseChargeService.createIncomeDaily",[parseInt(my.incomeItem_id),Date.parseDate(my.date, "Y/m/d"),parseFloat(my.amount),parseInt(my.familyMember_id),parseInt(my.bankAccount_id),my.remark],function(reply) { var sucess = reply.getResult(); if (sucess!=0) { alert("保存失败!"); } else { alert("保存成功!"); } }); addWindow.close(); } } },{ text: '放弃', handler: function(){ addWindow.close(); } }] }); var addWindow if(!addWindow){ addWindow = new Ext.Window({ id: 'incomeDaily-add-win', layout:'fit', width:500, height:300, plain: true, items:addForm }); } addWindow.show(this); addForm.form.setValues({date:(new Date()).format("Y/m/d"),familyMember_id:'1',bankAccount_id:'1',incomeItem_id:'2'}); addForm.form.render(); } function doQuery() { var allIncomeItem=[]; buffalo.remoteCall("houseChargeService.findRootIncomeItem",[], function(reply) { getChild(reply.getResult()); function getChild(parent) { if (parent.children.lengt==0) { return 0; } for(var i=0; i<parent.children.length; i++) { allIncomeItem.push([parent.children[i].id,parent.children[i].name]); getChild(parent.children[i]); } } }); //alert(allIncomeItem); var allFamilyMember=[]; buffalo.remoteCall("houseChargeService.getAllFamilyMember",[],function(reply) { var list = reply.getResult(); for(var i=0; i<list.length; i++) { allFamilyMember.push([list[i].id,list[i].name]); } }); var allBankAccount=[]; buffalo.remoteCall("houseChargeService.getAllBankAccount",[],function(reply) { var list = reply.getResult(); for(var i=0; i<list.length; i++) { if (list[i].bank=="现金") { allBankAccount.push([list[i].id,list[i].bank]); } else { allBankAccount.push([list[i].id,list[i].bank+" "+list[i].accountNo+list[i].cardNo]); } } }); var queryForm = new Ext.FormPanel({ onSubmit: Ext.emptyFn, submit: function() { this.getEl().dom.submit(); }, labelWidth: 75, // label settings here cascade unless overridden frame:true, title: '', //bodyStyle:'padding:5px 5px 0', ark bodyStyle:'padding: 0', width: 350, labelSeparator:'', items: [{ xtype:'fieldset', checkboxName:'queryFamilyMember_id', checkboxToggle:true, title: '按家庭成员查询', autoHeight:true, defaults: {width: 210}, collapsed: true, items :[{ xtype:'combo', fieldLabel: '家庭成员', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: allFamilyMember }), editable: false, hiddenName:'familyMember_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择家庭成员', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true }] },{ xtype:'fieldset', checkboxToggle:true, checkboxName:'queryDate', title: '按日期查询', autoHeight:true, defaults: {width: 210}, collapsed: true, items :[{ xtype:'datefield', fieldLabel: '日期起', name: 'dateFrom', width: 100, allowBlank: false, format:'Y/m/d' },{ xtype:'datefield', fieldLabel: '日期迄', name: 'dateTo', width: 100, allowBlank: false, format:'Y/m/d' }] },{ xtype:'fieldset', checkboxToggle:true, checkboxName:'queryAmount', title: '按金额查询', autoHeight:true, defaults: {width: 210}, collapsed: true, items :[{ xtype:'combo', fieldLabel: '运算符', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: [['<','小于'],['<=','小于等于'],['==','等于'],['>','大于'],['>=','大于等于']] }), editable: false, hiddenName:'cmp_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择运算符', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true },{ xtype:'numberfield', fieldLabel: '金额', name: 'amount', width: 100, allowBlank: false, allowNegative: false, minValue: 0 }] },{ xtype:'fieldset', checkboxToggle:true, checkboxName:'queryBankAccount_id', title: '按账户查询', autoHeight:true, defaults: {width: 210}, collapsed: true, items :[{ xtype:'combo', fieldLabel: '账户', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: allBankAccount }), editable: false, hiddenName:'bankAccount_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择账户', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true }] },{ xtype:'fieldset', checkboxToggle:true, checkboxName:'queryIncomeItem_id', title: '按收入项目查询', autoHeight:true, defaults: {width: 210}, collapsed: true, items :[{ xtype:'combo', fieldLabel: '收入项目', store: new Ext.data.SimpleStore({ fields: ["id","name"], data: allIncomeItem }), editable: false, hiddenName:'incomeItem_id', displayField:'name', valueField:'id', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'请选择收入项目', selectOnFocus:true, resizable:true, allowBlank:false, forceSelection:true }] } ], buttons: [{ text: '查询', handler:function(){ if(queryForm.form.isValid()){ var my=queryForm.form.getValues(); ds.proxy.dwrParams=[my.queryFamilyMember_id=='on'?true:false,parseInt(my.familyMember_id),my.queryDate=='on'?true:false,Date.parseDate(my.dateFrom, "Y/m/d"),Date.parseDate(my.dateTo, "Y/m/d"),my.queryAmount=='on'?true:false,my.cmp_id,parseFloat(my.amount),my.queryBankAccount_id=='on'?true:false,parseInt(my.bankAccount_id),my.queryIncomeItem_id=='on'?true:false,parseInt(my.incomeItem_id)]; ds.load({params:{start:0,limit:2}}); queryWindow.close(); } } },{ text: '退出', handler: function(){ queryWindow.close(); } }] }); var queryWindow if(!queryWindow){ queryWindow = new Ext.Window({ id: 'incomeDaily-query-win', layout:'fit', width:500, height:300, maximizable:true, plain: true, items:queryForm }); } queryWindow.show(this); queryForm.form.setValues({incomeItem_id:'2',dateFrom:(new Date(2007,1,1)).format("Y/m/d"),dateTo:(new Date()).format("Y/m/d"),familyMember_id:'1',bankAccount_id:'1',cmp_id:'>',amount:100,}); queryForm.form.render(); } function doDel(){ if(gridPanel.selModel.hasSelection()){ Ext.MessageBox.confirm('Message', '确定删除吗?' , doDelDetail); } else { Ext.MessageBox.alert('Error', '请选中一行'); } } function doDelDetail(btn) { if (btn == 'yes') { var record =gridPanel.selModel.getSelected(); if (record.get("id")==-1) { ds.remove(record); } else { buffalo.remoteCall("houseChargeService.deleteIncomeDaily",[record.get("id")],function(reply) { var sucess = reply.getResult(); if (sucess!=0) { alert("删除失败!"); } else { ds.remove(record); } }); } } } } });
dwrproxy.js
Ext.data.DWRProxy = function(dwrCall,dwrParams){ Ext.data.DWRProxy.superclass.constructor.call(this); this.dwrCall = dwrCall; this.dwrParams=dwrParams||[]; }; Ext.extend(Ext.data.DWRProxy, Ext.data.DataProxy, { load : function(params, reader, callback, scope, arg) { var self = this; if(this.fireEvent("beforeload", this, params) !== false) { var delegate = this.loadResponse.createDelegate(this, [reader, callback, scope, arg], 1); arg.params=arg.params||{}; var allParams=[arg.params.start||0,arg.params.limit||2].concat(this.dwrParams); allParams.push(delegate); this.dwrCall.apply(this,allParams); } else { callback.call(scope || this, null, arg, false); } }, loadResponse : function(listRange, reader, callback, scope, arg) { var result; try { result = reader.readRecords(listRange); } catch(e) { this.fireEvent("loadexception", this, null,listRange, e); callback.call(scope, null, arg, false); return; } callback.call(scope, result, arg, true); } });
评论
4 楼
xiang
2007-11-21
楼主打包一下,方便大家下载啊
3 楼
thinger
2007-11-20
第一感觉:结构非常清晰
2 楼
ksgimi
2007-11-20
application_context.xml
dwr.xml
web.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property> <property name="url"><value>jdbc:hsqldb:data/database</value></property> <property name="username"><value>sa</value></property> <property name="password"><value></value></property> </bean> <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.cache.use_query_cache">true</prop> </props> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"><ref bean="dataSource"/></property> <property name="mappingResources"> <list> <value>com/ark/common/domain/Entity.hbm.xml</value> <value>com/ark/housecharge/domain/Entity.hbm.xml</value> </list> </property> <property name="hibernateProperties"><ref bean="hibernateProperties"/></property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <aop:config> <aop:advisor pointcut="execution(* com.ark.housecharge.service..*.*(..))" advice-ref="txAdvice"/> <!-- <aop:advisor pointcut="execution(* com.ark.common.service..*.*(..))" advice-ref="txAdvice"/> --> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="loadById" read-only="true" /> <tx:method name="loadByName" read-only="true" /> <tx:method name="*"/> </tx:attributes> </tx:advice> <bean id="houseChargeServiceTarget" class="com.ark.housecharge.service.impl.HouseChargeServiceImpl"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="houseChargeService" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>com.ark.housecharge.service.HouseChargeService</value></property> <property name="interceptorNames"> <list> <idref bean="serviceManagerSecurity"/> <idref local="houseChargeServiceTarget"/> </list> </property> </bean> <bean id="securityService" class="com.ark.common.service.impl.SecurityServiceImpl"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean name="buffaloConfigBean" class="net.buffalo.service.BuffaloServiceConfigurer"> <property name="services"> <map> <entry key="houseChargeService"><ref bean="houseChargeService"/></entry> <!-- oterh entries... --> </map> </property> </bean> </beans>
dwr.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.ltd.uk/dwr/dwr20.dtd"> <dwr> <allow> <create creator="spring" javascript="houseChargeService" scope="script"> <param name="beanName" value="houseChargeService"/> <!-- <include method="getAllBankAccount"/> --> </create> <convert match="com.ark.common.domain.ExtGridResult" converter="hibernate3"/> <convert match="com.ark.housecharge.domain.IncomeDaily" converter="hibernate3"/> <convert match="com.ark.housecharge.domain.IncomeItem" converter="hibernate3"/> <convert match="com.ark.housecharge.domain.IncomeItem" converter="hibernate3"/> <convert match="com.ark.housecharge.domain.FamilyMember" converter="hibernate3"/> <convert match="com.ark.housecharge.domain.BankAccount" converter="hibernate3"/> </allow> </dwr>
web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>House Charge Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/com/ark/housecharge/application_context.xml classpath:/com/ark/housecharge/applicationContext-acegi-security.xml classpath:/com/ark/housecharge/applicationContext-acegi-service.xml </param-value> </context-param> <filter> <filter-name>opensession</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>acegi</filter-name> <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>org.acegisecurity.util.FilterChainProxy</param-value> </init-param> </filter> <filter-mapping> <filter-name>opensession</filter-name> <url-pattern>/bfapp/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>opensession</filter-name> <url-pattern>/dwr/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>acegi</filter-name> <url-pattern>*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.acegisecurity.ui.session.HttpSessionEventPublisher</listener-class> </listener> <servlet> <servlet-name>bfapp</servlet-name> <servlet-class>net.buffalo.web.servlet.ApplicationServlet</servlet-class> </servlet> <servlet> <servlet-name>dwr-invoker</servlet-name> <display-name>DWR Servlet</display-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>bfapp</servlet-name> <url-pattern>/bfapp/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <taglib> <taglib-uri>authz</taglib-uri> <taglib-location>http://acegisecurity.org/authz</taglib-location> </taglib> </web-app>
1 楼
ksgimi
2007-11-20
buffalo 处理javascript->java很好,但处理java->javascript时不够细腻,比如日期类型。dwr则好一些。
ExtGridResult.java
HouseChargeServiceImpl.java
BaseServiceImpl.java
ExtGridResult.java
package com.ark.common.domain; import java.util.List; public class ExtGridResult<E> { private int total; private List<E> list; public ExtGridResult(int total,List<E> list) { this.total=total; this.list=list; } public int getTotal() { return total; } public void setTotal(int total) { this.total = total; } public List<E> getList() { return list; } public void setList(List<E> list) { this.list = list; } }
HouseChargeServiceImpl.java
package com.ark.housecharge.service.impl; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.ark.common.domain.Entity; import com.ark.common.domain.ExtGridResult; import com.ark.common.service.impl.BaseServiceImpl; import com.ark.housecharge.domain.ChargeItem; import com.ark.housecharge.domain.IncomeItem; import com.ark.housecharge.domain.BankAccount; import com.ark.housecharge.domain.FamilyMember; import com.ark.housecharge.domain.TransferDaily; import com.ark.housecharge.domain.IncomeDaily; import com.ark.housecharge.domain.ConsumeDaily; import com.ark.housecharge.service.HouseChargeService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Criterion; public class HouseChargeServiceImpl extends BaseServiceImpl implements HouseChargeService { private static final Log log = LogFactory.getLog(HouseChargeServiceImpl.class); public int createFamilyMember(String name) { FamilyMember familyMember=new FamilyMember(); familyMember.setName(name); this.create(familyMember); return 0; } public int updateFamilyMember(Long id,String name) { FamilyMember familyMember=(FamilyMember)this.loadById(FamilyMember.class,id); familyMember.setName(name); this.create(familyMember); return 0; } public int deleteFamilyMember(Long id) { FamilyMember familyMember=(FamilyMember)this.loadById(FamilyMember.class,id); this.delete(familyMember); return 0; } public List<FamilyMember> getAllFamilyMember() { return (List<FamilyMember>)(this.findAll(FamilyMember.class)); } public int createBankAccount(String bank,String accountNo,String cardNo,Date openDate,float openAmount){ BankAccount bankAccount=new BankAccount(); bankAccount.setBank(bank); bankAccount.setAccountNo(accountNo); bankAccount.setCardNo(cardNo); bankAccount.setOpenDate(openDate); bankAccount.setOpenAmount(openAmount); bankAccount.setBalDate(openDate); bankAccount.setBalAmount(openAmount); this.create(bankAccount); return 0; } public int updateBankAccount(Long id,String bank,String accountNo,String cardNo) { BankAccount bankAccount=(BankAccount)this.loadById(BankAccount.class,id); bankAccount.setBank(bank); bankAccount.setAccountNo(accountNo); bankAccount.setCardNo(cardNo); this.update(bankAccount); return 0; } public int deleteBankAccount(Long id) { BankAccount bankAccount=(BankAccount)this.loadById(BankAccount.class,id); this.delete(bankAccount); return 0; } public List<BankAccount> getAllBankAccount() { return (List<BankAccount>)(this.findAll(BankAccount.class)); } public ChargeItem createChargeItem(int parentId,String chargeName) { ChargeItem parentChargeItem=(ChargeItem)this.loadById(ChargeItem.class,new Long(parentId)); ChargeItem chargeItem=new ChargeItem(); chargeItem.setParent(parentChargeItem); chargeItem.setName(chargeName); this.create(chargeItem); return chargeItem; } public ChargeItem updateChargeItem(int id,String chargeName) { ChargeItem chargeItem=(ChargeItem)this.loadById(ChargeItem.class,new Long(id)); chargeItem.setName(chargeName); this.update(chargeItem); return chargeItem; } public int deleteChargeItem(int id) { ChargeItem chargeItem=(ChargeItem)this.loadById(ChargeItem.class,new Long(id)); this.delete(chargeItem); return 0; } private void createRootChargeItem(){ log.info("begin execute createRootChargeItem "); ChargeItem chargeItem=new ChargeItem(); chargeItem.setName(ChargeItem.ROOT_ITEM_NAME); super.create((Entity)chargeItem); log.info("end execute createRootChargeItem "); } public ChargeItem findRootChargeItem() { List<ChargeItem> list=super.find(ChargeItem.class,Restrictions.isNull("parent")); if (list==null||list.isEmpty()){ createRootChargeItem(); return findRootChargeItem(); } else { return list.get(0); } } public IncomeItem createIncomeItem(int parentId,String incomeName) { IncomeItem parentIncomeItem=(IncomeItem)this.loadById(IncomeItem.class,new Long(parentId)); IncomeItem incomeItem=new IncomeItem(); incomeItem.setParent(parentIncomeItem); incomeItem.setName(incomeName); this.create(incomeItem); return incomeItem; } public IncomeItem updateIncomeItem(int id,String incomeName) { IncomeItem incomeItem=(IncomeItem)this.loadById(IncomeItem.class,new Long(id)); incomeItem.setName(incomeName); this.update(incomeItem); return incomeItem; } public int deleteIncomeItem(int id) { IncomeItem incomeItem=(IncomeItem)this.loadById(IncomeItem.class,new Long(id)); this.delete(incomeItem); return 0; } private void createRootIncomeItem(){ IncomeItem incomeItem=new IncomeItem(); incomeItem.setName(IncomeItem.ROOT_ITEM_NAME); super.create((Entity)incomeItem); } public IncomeItem findRootIncomeItem() { List<IncomeItem> list=super.find(IncomeItem.class,Restrictions.isNull("parent")); if (list==null||list.isEmpty()){ createRootIncomeItem(); return findRootIncomeItem(); } else { return list.get(0); } } public int createIncomeDaily(int incomeItem_id,Date date,Float amount, int familyMember_id, int bankAccount_id,String remark) { IncomeItem incomeItem=(IncomeItem)this.loadById(IncomeItem.class,new Long(incomeItem_id)); FamilyMember familyMember=(FamilyMember)this.loadById(FamilyMember.class,new Long(familyMember_id)); BankAccount bankAccount=(BankAccount)this.loadById(BankAccount.class,new Long(bankAccount_id)); IncomeDaily incomeDaily=new IncomeDaily(); incomeDaily.setAmount(amount); incomeDaily.setDate(date); incomeDaily.setIncomeItem(incomeItem); incomeDaily.setBankAccount(bankAccount); incomeDaily.setFamilyMember(familyMember); incomeDaily.setRemark(remark); bankAccount.incomeAmount(incomeDaily.getDate(),incomeDaily.getAmount()); super.update(bankAccount); super.create(incomeDaily); return 0; } public int deleteIncomeDaily(int incomeDaily_id) { IncomeDaily incomeDaily=(IncomeDaily)this.loadById(IncomeDaily.class,new Long(incomeDaily_id)); incomeDaily.getBankAccount().deIncomeAmount(incomeDaily.getDate(),incomeDaily.getAmount()); super.update(incomeDaily.getBankAccount()); super.delete(incomeDaily); return 0; } public int updateIncomeDaily(int incomeDaily_id, int incomeItem_id,Date date,Float amount, int familyMember_id, int bankAccount_id,String remark) { IncomeDaily incomeDaily=(IncomeDaily)this.loadById(IncomeDaily.class,new Long(incomeDaily_id)); incomeDaily.getBankAccount().deIncomeAmount(incomeDaily.getDate(), incomeDaily.getAmount()); super.update(incomeDaily.getBankAccount()); IncomeItem incomeItem=(IncomeItem)this.loadById(IncomeItem.class,new Long(incomeItem_id)); FamilyMember familyMember=(FamilyMember)this.loadById(FamilyMember.class,new Long(familyMember_id)); BankAccount bankAccount=(BankAccount)this.loadById(BankAccount.class,new Long(bankAccount_id)); incomeDaily.setAmount(amount); incomeDaily.setDate(date); incomeDaily.setIncomeItem(incomeItem); incomeDaily.setBankAccount(bankAccount); incomeDaily.setFamilyMember(familyMember); bankAccount.incomeAmount(incomeDaily.getDate(),incomeDaily.getAmount()); super.update(bankAccount); super.update(incomeDaily); return 0; } public ExtGridResult<IncomeDaily> findIncomeDaily(int start,int limit,Boolean queryFamilyMember_id,int familyMember_id,Boolean queryDate,Date dateFrom,Date dateTo,Boolean queryAmount,String cmp_id,Float amount, Boolean queryBankAccount_id,int bankAccount_id,Boolean queryIncomeItem_id,int incomeItem_id) { List<Criterion> clist=new ArrayList<Criterion>(); if (queryFamilyMember_id) { clist.add(Restrictions.eq("familyMember.id",familyMember_id)); } if (queryDate) { clist.add(Restrictions.between("date",dateFrom,dateTo)); } if (queryAmount) { clist.add(Restrictions.sqlRestriction(" amount"+ cmp_id+amount.toString())); } if (queryBankAccount_id) { clist.add(Restrictions.eq("bankAccount.id",bankAccount_id)); } if (queryIncomeItem_id) { clist.add(Restrictions.eq("incomeItem.id",incomeItem_id)); } return super.find(IncomeDaily.class,clist,start,limit); } }
BaseServiceImpl.java
package com.ark.common.service.impl; import java.io.Serializable; import java.sql.SQLException; import java.util.List; import com.ark.common.domain.NamedEntity; import com.ark.common.service.BaseService; import com.ark.common.domain.ExtGridResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Projections; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class BaseServiceImpl extends HibernateDaoSupport implements BaseService{ protected static final Log log = LogFactory.getLog(BaseServiceImpl.class); @SuppressWarnings("unchecked") public <T> T loadById(final Class<T> cls,Serializable id) { return (T) getHibernateTemplate().get(cls,id); } @SuppressWarnings("unchecked") public<T> T loadByName(final Class<? extends NamedEntity> cls,final String name) { return (T)getHibernateTemplate().execute(new HibernateCallback() { public T doInHibernate(Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(cls); criteria.add(Restrictions.eq("name",name)); List<T> list=criteria.list(); if (list==null||list.isEmpty()){ return null; } else { return (T)list.get(0); } } }); } public void create(Object entity) { getHibernateTemplate().save(entity); } public void update(Object entity) { getHibernateTemplate().update(entity); } public void delete(Object entity) { getHibernateTemplate().delete(entity); } @SuppressWarnings("unchecked") public <T> List<T> findAll(final Class<T> cls) { return getHibernateTemplate().find("from " + cls.getName()); } @SuppressWarnings("unchecked") public <T> List<T> find(final Class<T> cls,final Criterion c) { return (List<T>) getHibernateTemplate().execute(new HibernateCallback() { public List<T> doInHibernate(Session session) throws HibernateException, SQLException { return session.createCriteria(cls).add(c).list(); } }); } @SuppressWarnings("unchecked") public <T> List<T> find(final Class<T> cls,final List<Criterion> list) { return (List<T>) getHibernateTemplate().execute(new HibernateCallback() { public List<T> doInHibernate(Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(cls); for (Criterion c:list) { criteria.add(c); } return criteria.list(); } }); } @SuppressWarnings("unchecked") public <T> ExtGridResult<T> find(final Class<T> cls,final List<Criterion> list,final int start,final int limit) { return (ExtGridResult<T>) getHibernateTemplate().execute(new HibernateCallback() { public ExtGridResult<T> doInHibernate(Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(cls); for (Criterion c:list) { criteria.add(c); } int total=(Integer)criteria.setProjection(Projections.rowCount()).uniqueResult(); criteria.setProjection(null); List<T> list= criteria.setFirstResult(start).setMaxResults(limit).list(); return new ExtGridResult(total,list); } }); } }
相关推荐
Ext slider扩展以级范例代码----下载不扣分,回帖加1分,欢迎下载,童叟无欺Ext slider扩展以级范例代码----下载不扣分,回帖加1分,欢迎下载,童叟无欺Ext slider扩展以级范例代码----下载不扣分,回帖加1分,欢迎...
EXT4.2 MVC范例代码主要展示了如何在编程中应用EXT4.2框架与MVC(Model-View-Controller)设计模式相结合的方式进行项目开发。EXT4.2是一款流行的JavaScript库,专门用于构建富客户端应用程序,它提供了丰富的UI组件...
ExtJS 是一个强大的JavaScript库,专门用于构建富客户端应用程序,尤其在企业级Web应用中广泛应用。这个压缩包文件包含的示例和资源主要展示了如何利用ExtJS实现数据操作(增删改查)以及树形视图(TreePanel)的...
标题 "GWT+EXT+STRUTS2+Eclipse完整范例.rar" 提示我们这是一个包含一个集成开发环境Eclipse的项目,该项目集成了Google Web Toolkit (GWT), EXT JS 和Struts2框架。描述 "整合 GWT EXT STRUTS2 Eclipse 范例" 明确...
3.1. 真的,我是为了树,才开始学ext的。 3.2. 传统是先做出一棵树来。 3.3. 超越一个根 3.4. 你不会认为2.0里跟1.x是一样的吧? 3.5. 这种装配树节点的形式,真是让人头大。 3.6. jsp的例子是一定要有的 3.7. 让你...
文档中提到的范例会展示如何使用Ext JS 4的不同特性,比如数据模型(Models)、视图(View)、控制器(Controller)等,以及如何将它们集成到一个可运行的应用程序中。 3. **Ext JS 4组件(Components)** Ext JS ...
龙博Ext Gantt甘特图最新2.07破解+中文包 ext-gantt\gnt-all-debug.js ext-gantt\sch-lang-zh_CN.js ext-min\ext-lang-zh_CN.js http://www.longboo.com/ http://bryntum.com/
### Ext2.0框架的Grid使用介绍 #### 一、Ext2.0框架概述 Ext2.0是一款基于JavaScript的库,它提供了丰富的用户界面组件和API,使得开发者能够快速地构建出高度交互性的Web应用。与其他框架如YUI相比,Ext2.0拥有...
**基于Struts的Ext增删改查应用范例详解** 在Web开发中,Struts框架与ExtJS库的结合常用于构建高效的用户界面和后台数据交互。本应用范例是针对初学者的一个宝贵资源,它提供了清晰的注释和全面的功能,使开发者...
3.1. 真的,我是为了树,才开始学ext的。 3.2. 传统是先做出一棵树来。 3.3. 超越一个根 3.4. 对tree进行统一配置 3.5. 这种装配树节点的形式,真是让人头大。 3.5.1. TreeLoader外传 之 JsonPlugin 3.5.2. ...
7. **范例和教程**:通常,中文版文档还会包含丰富的示例代码和教程,帮助初学者快速上手,理解如何实际应用这些概念和技术。 8. **国际化支持**:对于多语言应用,ExtJS提供了内置的国际化支持,使得应用能够轻松...
Ext 2 中文文档 在众多的AJAX框架中,考察一个框架是否优秀,除了强调框架的功能、性能外,掌握难度和相关的文档、范例也是参考要数。ExtJS便是这样一个不错的选择。当感觉到ExtJS的强大的同时,也发现这个框架国内...
这样的组合既提高了用户体验,又降低了服务器负载,是现代Web应用开发的一个典型范例。通过学习和理解这个示例,开发者可以深化对这些技术的理解,并将其运用到自己的项目中,提升开发效率和应用性能。
Oryx 加上 Ext 修改范例,实现在oryx上添加tab窗体
ext框架本人自学笔记,使用频率很高的ext框架技术源代码,可以直接COPY粘贴到自己程序中,稍微改动一下就可以使用
在MFC中,我们可以使用`AFX_EXT_CLASS`宏来声明导出的MFC类,这样就可以在DLL中定义和实现类,然后在主应用程序中实例化和使用。同时,MFC还提供了`AfxBeginThread`函数,用于在DLL中创建线程,以及`...
Struts是Java Web开发中的一款经典MVC框架,它的全称是Apache Struts,由Apache软件基金会维护。这个框架主要用于构建基于J2EE的Web应用程序,提供了一种组织应用程序结构和控制应用程序流程的方式。...
ext 的入门级别的范例
ExtJS实例 一个非常不错的学习Ext的源码
最后,"S7_sample_project_ext_Busposi_6PDs"可能涉及外部总线定位,用于六个电机的控制。这个范例可能会深入讲解如何在更大的系统中实现复杂的定位控制,可能包括更高级的通讯协议,如PROFIBUS或PROFINET,以及如何...