ITPub博客

首页 > 应用开发 > IT综合 > ext例子

ext例子

原创 IT综合 作者:melson 时间:2008-01-26 22:33:02 0 删除 编辑

main.jsp

  1. <%@ page contentType="text/html; charset=utf-8"%>
  2. <%@ page import="org.acegisecurity.context.SecurityContext, org.acegisecurity.userdetails.UserDetails" %>
  3. "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  4. House Charge Expenses System
  5. "content-type" content="text/html; charset=utf-8" />
  6. "content-language" content="utf-8" />
  7. "all" name="robots" />
  8. "author" content="ark"/>
  9. "copyright" content="ark" />
  10. "description" content="just for testing" />
  11. "keywords" content="family,finance,study" />
  12. "stylesheet" type="text/css" href="<%=request.getContextPath() %>/ajaxlib/ext/resources/css/ext-all.css" />
  13. "stylesheet" type="text/css" href="<%=request.getContextPath() %>/ajaxlib/mylib/ext-patch.css" />
  14. "stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/windows.css" />
  15. <!--buffalo-->
  16. "x-taskbar">
  17. "title-bar">House Charge Expenses System
  18. "logname">用户名:class="username">
  19. <%
  20. SecurityContext context=(SecurityContext)request.getSession().getAttribute("ACEGI_SECURITY_CONTEXT");
  21. UserDetails userDetails=(UserDetails)context.getAuthentication().getPrincipal();
  22. out.print(userDetails.getUsername());
  23. %>
  24. | "<%=request.getContextPath() %>/logout.html">登出
  • "x-launcher-wrap">
    "x-launcher-inner">
    "x-launcher-left">
    "x-launcher-right">
    "x-launcher-center">
    "x-launcher">
    "x-info">
  • "x-desktop">
  • "x-windows">
  • "x-winlist">
    "spacer">
  • class="x-clear">
  • windows.js

    1. Myapp = new Ext.app.App({
    2. init :function(){
    3. Ext.QuickTips.init();
    4. },
    5. getModules : function(){
    6. return [
    7. new chargeItemWindow(),
    8. new incomeItemWindow(),
    9. new familyMemberWindow(),
    10. new bankAccountWindow(),
    11. new incomeDailyWindow(),
    12. ];
    13. }
    14. });

    familyMember.js

    1. familyMemberWindow = Ext.extend(Ext.app.Module, {
    2. init : function(){
    3. this.launcher = {
    4. text: '家庭成员',
    5. iconCls:'icon-grid',
    6. handler : this.createWindow,
    7. scope: this
    8. }
    9. },
    10. createWindow : function(){
    11. var desktop = this.app.getDesktop();
    12. var cm = new Ext.grid.ColumnModel([{
    13. header: '姓名',
    14. dataIndex: 'name',
    15. width: 220,
    16. editor: new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank: false}))
    17. }]);
    18. // by default columns are sortable
    19. cm.defaultSortable = true;
    20. var FamilyMember = Ext.data.Record.create([
    21. {name:'id',type:'int',mapping:'id'},
    22. {name: 'name',type:'string',mapping: 'name'}
    23. ]);
    24. var ds = new Ext.data.Store({
    25. proxy: new Buffalo.Ext.DataProxy(buffalo,"houseChargeService.getAllFamilyMember",[]),
    26. reader: new Ext.data.ArrayReader({id: 'id'}, FamilyMember),
    27. // turn off remote sorting
    28. remoteSort: false
    29. });
    30. var gridPanel = new Ext.grid.EditorGridPanel({
    31. store: ds,
    32. cm: cm,
    33. selModel: new Ext.grid.CellSelectionModel(),
    34. enableColLock:false,
    35. buttonAlign:'top',
    36. tbar:[{
    37. text: '新增',
    38. handler :doAdd
    39. },{
    40. text: '保存',
    41. handler : doSave
    42. },{
    43. text: '删除',
    44. handler : doDel
    45. }]
    46. });
    47. var win = desktop.getWindow('familyMember-win');
    48. if(!win){
    49. win = desktop.createWindow({
    50. id: 'familyMember-win',
    51. title:'家庭成员',
    52. width:740,
    53. height:460,
    54. x:10,
    55. y:10,
    56. iconCls: 'icon-grid',
    57. shim:false,
    58. animCollapse:false,
    59. constrainHeader:true,
    60. layout: 'fit',
    61. items: gridPanel
    62. });
    63. }
    64. ds.load();
    65. win.show();
    66. function doAdd() {
    67. var p = new FamilyMember({
    68. id:-1,
    69. name:''
    70. });
    71. gridPanel.stopEditing();
    72. var yetCount=ds.getCount();
    73. ds.insert(yetCount, p);
    74. //标示cell已修改过
    75. ds.getAt(yetCount).set("name",'未命名');
    76. gridPanel.startEditing(yetCount, 0);
    77. }
    78. function doSave() {
    79. var eds=ds.getModifiedRecords().slice(0);
    80. for(var i = 0;i
    81. record =eds[i];
    82. if (record.get("id")==-1) {
    83. buffalo.remoteCall("houseChargeService.createFamilyMember",[record.get("name")],function(reply) {
    84. var sucess = reply.getResult();
    85. if (sucess==1) {
    86. alert("重复姓名!");
    87. } else {
    88. if (sucess!=0) {
    89. alert("保存失败!");
    90. } else {
    91. record.commit();
    92. }
    93. }
    94. });
    95. } else {
    96. buffalo.remoteCall("houseChargeService.updateFamilyMember",[record.get("id"),record.get("name")],function(reply) {
    97. var sucess = reply.getResult();
    98. if (sucess==1) {
    99. alert("重复姓名!");
    100. } else {
    101. if (sucess!=0) {
    102. alert("保存失败!");
    103. } else {
    104. record.commit();
    105. }
    106. }
    107. });
    108. }
    109. }
    110. }
    111. function doDel(){
    112. if(gridPanel.selModel.hasSelection()){
    113. Ext.MessageBox.confirm('Message', '确定删除吗?', doDelDetail);
    114. } else {
    115. Ext.MessageBox.alert('Error', '请选中一行!');
    116. }
    117. }
    118. function doDelDetail(btn) {
    119. if (btn == 'yes') {
    120. var record = ds.getAt(gridPanel.selModel.getSelectedCell()[0]);
    121. if (record.get("id")==-1) {
    122. ds.remove(record);
    123. } else {
    124. buffalo.remoteCall("houseChargeService.deleteFamilyMember",[record.get("id")],function(reply) {
    125. var sucess = reply.getResult();
    126. if (sucess!=0) {
    127. alert(" 删除失败!");
    128. } else {
    129. ds.remove(record);
    130. }
    131. });
    132. }
    133. }
    134. }
    135. }
    136. });

    incomeDaily.js

    1. incomeDailyWindow = Ext.extend(Ext.app.Module, {
    2. init : function(){
    3. this.launcher = {
    4. text: '收入日记录',
    5. iconCls:'icon-grid',
    6. handler : this.createWindow,
    7. scope: this
    8. }
    9. },
    10. createWindow : function(){
    11. var desktop = this.app.getDesktop();
    12. Ext.QuickTips.init();
    13. Ext.form.Field.prototype.msgTarget = 'side';
    14. var cm = new Ext.grid.ColumnModel([
    15. {
    16. header: "收入项目",
    17. sortable: true,
    18. dataIndex: 'incomeItem_name',
    19. width: 100
    20. },{
    21. header: "日期",
    22. dataIndex: 'date',
    23. width:60,
    24. renderer:Ext.util.Format.dateRenderer('Y/m/d')
    25. },{
    26. header: "金额",
    27. dataIndex: 'amount',
    28. align: 'right',
    29. width: 100
    30. },{
    31. header: "家庭成员",
    32. dataIndex: 'familyMember_name',
    33. width: 80
    34. },{
    35. header: "银行",
    36. dataIndex: 'bankAccount_bank',
    37. width: 120
    38. },{
    39. header: "帐号",
    40. dataIndex: 'bankAccount_accountNo',
    41. width: 120
    42. },{
    43. header:"备注",
    44. dataIndex: 'remark',
    45. width: 80
    46. }]);
    47. // by default columns are sortable
    48. cm.defaultSortable = true;
    49. var IncomeDaily = Ext.data.Record.create([
    50. {name:'id',type:'int',mapping:'id'},
    51. {name: 'incomeItem_name', type: 'string',mapping:'incomeItem.name'},
    52. {name: 'date', type: 'date',dateFormat: 'Y/m/d',mapping:'date'},
    53. {name: 'amount', type: 'float',mapping:'amount'},
    54. {name: 'familyMember_name', type: 'string',mapping:'familyMember.name'},
    55. {name: 'bankAccount_bank', type: 'string',mapping:'bankAccount.bank'},
    56. {name: 'bankAccount_accountNo', type: 'string',mapping:'bankAccount.accountNo'},
    57. {name: 'remark', type: 'string',mapping:'remark'}
    58. ]);
    59. var ds = new Ext.data.Store({
    60. proxy: new Ext.data.DWRProxy(houseChargeService.findIncomeDaily),
    61. reader: new Ext.data.JsonReader({totalProperty:'total',root:'list',id:'id'},IncomeDaily),
    62. remoteSort: false,
    63. });
    64. var gridPanel = new Ext.grid.EditorGridPanel({
    65. ds:ds,
    66. cm: cm,
    67. sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
    68. enableColLock:false,
    69. autoSizeColumns: true,
    70. buttonAlign:'top',
    71. tbar:[{
    72. text: '新增',
    73. handler :doAdd
    74. },{
    75. text: '查询',
    76. handler : doQuery
    77. },{
    78. text: '删除',
    79. handler : doDel
    80. }],
    81. bbar:new Ext.PagingToolbar({
    82. pageSize: 2,
    83. store: ds,
    84. displayInfo: true
    85. })
    86. });
    87. var win = desktop.getWindow('incomeDaily-win');
    88. if(!win){
    89. win = desktop.createWindow({
    90. id: 'incomeDaily-win',
    91. title:'收入日记录',
    92. width:740,
    93. height:460,
    94. x:10,
    95. y:10,
    96. iconCls: 'icon-grid',
    97. shim:false,
    98. animCollapse:false,
    99. constrainHeader:true,
    100. layout: 'fit',
    101. items: gridPanel
    102. });
    103. }
    104. win.show();
    105. function doAdd() {
    106. var allIncomeItem=[];
    107. buffalo.remoteCall("houseChargeService.findRootIncomeItem",[], function(reply) {
    108. getChild(reply.getResult());
    109. function getChild(parent) {
    110. if (parent.children.lengt==0) {
    111. return 0;
    112. }
    113. for(var i=0; i
    114. allIncomeItem.push([parent.children[i].id,parent.children[i].name]);
    115. getChild(parent.children[i]);
    116. }
    117. }
    118. });
    119. var allFamilyMember=[];
    120. buffalo.remoteCall("houseChargeService.getAllFamilyMember",[],function(reply) {
    121. var list = reply.getResult();
    122. for(var i=0; i
    123. allFamilyMember.push([list[i].id,list[i].name]);
    124. }
    125. });
    126. var allBankAccount=[];
    127. buffalo.remoteCall("houseChargeService.getAllBankAccount",[],function(reply) {
    128. var list = reply.getResult();
    129. for(var i=0; i
    130. if (list[i].bank=="现金") {
    131. allBankAccount.push([list[i].id,list[i].bank]);
    132. } else {
    133. allBankAccount.push([list[i].id,list[i].bank+" "+list[i].accountNo+" "+list[i].cardNo]);
    134. }
    135. }
    136. });
    137. var addForm = new Ext.FormPanel({
    138. onSubmit: Ext.emptyFn,
    139. submit: function() {
    140. this.getEl().dom.submit();
    141. },
    142. labelWidth: 75, // label settings here cascade unless overridden
    143. frame:true,
    144. title: '',
    145. //bodyStyle:'padding:5px 5px 0', ark
    146. bodyStyle:'padding: 0',
    147. width: 350,
    148. labelSeparator:'',
    149. items: [{
    150. xtype:'combo',
    151. fieldLabel: '家庭成员',
    152. store: new Ext.data.SimpleStore({
    153. fields: ["id","name"],
    154. data: allFamilyMember
    155. }),
    156. editable: false,
    157. hiddenName:'familyMember_id',
    158. displayField:'name',
    159. valueField:'id',
    160. typeAhead: true,
    161. mode: 'local',
    162. triggerAction: 'all',
    163. emptyText:'请选择家庭成员',
    164. selectOnFocus:true,
    165. resizable:true,
    166. allowBlank:false,
    167. forceSelection:true
    168. },{
    169. xtype:'datefield',
    170. fieldLabel: '日期',
    171. name: 'date',
    172. width: 100,
    173. allowBlank: false,
    174. format:'Y/m/d'
    175. }, {
    176. xtype:'numberfield',
    177. fieldLabel: '金额',
    178. name: 'amount',
    179. width: 100,
    180. allowBlank: false,
    181. allowNegative: false,
    182. minValue: 0
    183. },{
    184. xtype:'combo',
    185. fieldLabel: '账户',
    186. store: new Ext.data.SimpleStore({
    187. fields: ["id","name"],
    188. data: allBankAccount
    189. }),
    190. editable: false,
    191. hiddenName:'bankAccount_id',
    192. displayField:'name',
    193. valueField:'id',
    194. typeAhead: true,
    195. mode: 'local',
    196. triggerAction: 'all',
    197. emptyText:'请选择账户',
    198. selectOnFocus:true,
    199. resizable:true,
    200. allowBlank:false,
    201. forceSelection:true
    202. },{
    203. xtype:'combo',
    204. fieldLabel: '收入项目',
    205. store: new Ext.data.SimpleStore({
    206. fields: ["id","name"],
    207. data: allIncomeItem
    208. }),
    209. editable: false,
    210. hiddenName:'incomeItem_id',
    211. displayField:'name',
    212. valueField:'id',
    213. typeAhead: true,
    214. mode: 'local',
    215. triggerAction: 'all',
    216. emptyText:'请选择收入项目',
    217. selectOnFocus:true,
    218. resizable:true,
    219. allowBlank:false,
    220. forceSelection:true
    221. },{
    222. xtype:'textfield',
    223. fieldLabel: '备注',
    224. name: 'remark',
    225. width:300
    226. }
    227. ],
    228. buttons: [{
    229. text: '保存',
    230. handler:function(){
    231. if(addForm.form.isValid()){
    232. var my=addForm.form.getValues();
    233. 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) {
    234. var sucess = reply.getResult();
    235. if (sucess!=0) {
    236. alert("保存失败!");
    237. } else {
    238. alert("保存成功!");
    239. }
    240. });
    241. addWindow.close();
    242. }
    243. }
    244. },{
    245. text: '放弃',
    246. handler: function(){
    247. addWindow.close();
    248. }
    249. }]
    250. });
    251. var addWindow
    252. if(!addWindow){
    253. addWindow = new Ext.Window({
    254. id: 'incomeDaily-add-win',
    255. layout:'fit',
    256. width:500,
    257. height:300,
    258. plain: true,
    259. items:addForm
    260. });
    261. }
    262. addWindow.show(this);
    263. addForm.form.setValues({date:(new Date()).format("Y/m/d"),familyMember_id:'1',bankAccount_id:'1',incomeItem_id:'2'});
    264. addForm.form.render();
    265. }
    266. function doQuery() {
    267. var allIncomeItem=[];
    268. buffalo.remoteCall("houseChargeService.findRootIncomeItem",[], function(reply) {
    269. getChild(reply.getResult());
    270. function getChild(parent) {
    271. if (parent.children.lengt==0) {
    272. return 0;
    273. }
    274. for(var i=0; i
    275. allIncomeItem.push([parent.children[i].id,parent.children[i].name]);
    276. getChild(parent.children[i]);
    277. }
    278. }
    279. });
    280. //alert(allIncomeItem);
    281. var allFamilyMember=[];
    282. buffalo.remoteCall("houseChargeService.getAllFamilyMember",[],function(reply) {
    283. var list = reply.getResult();
    284. for(var i=0; i
    285. allFamilyMember.push([list[i].id,list[i].name]);
    286. }
    287. });
    288. var allBankAccount=[];
    289. buffalo.remoteCall("houseChargeService.getAllBankAccount",[],function(reply) {
    290. var list = reply.getResult();
    291. for(var i=0; i
    292. if (list[i].bank=="现金") {
    293. allBankAccount.push([list[i].id,list[i].bank]);
    294. } else {
    295. allBankAccount.push([list[i].id,list[i].bank+" "+list[i].accountNo+list[i].cardNo]);
    296. }
    297. }
    298. });
    299. var queryForm = new Ext.FormPanel({
    300. onSubmit: Ext.emptyFn,
    301. submit: function() {
    302. this.getEl().dom.submit();
    303. },
    304. labelWidth: 75, // label settings here cascade unless overridden
    305. frame:true,
    306. title: '',
    307. //bodyStyle:'padding:5px 5px 0', ark
    308. bodyStyle:'padding: 0',
    309. width: 350,
    310. labelSeparator:'',
    311. items: [{
    312. xtype:'fieldset',
    313. checkboxName:'queryFamilyMember_id',
    314. checkboxToggle:true,
    315. title: '按家庭成员查询',
    316. autoHeight:true,
    317. defaults: {width: 210},
    318. collapsed: true,
    319. items :[{
    320. xtype:'combo',
    321. fieldLabel: '家庭成员',
    322. store: new Ext.data.SimpleStore({
    323. fields: ["id","name"],
    324. data: allFamilyMember
    325. }),
    326. editable: false,
    327. hiddenName:'familyMember_id',
    328. displayField:'name',
    329. valueField:'id',
    330. typeAhead: true,
    331. mode: 'local',
    332. triggerAction: 'all',
    333. emptyText:'请选择家庭成员',
    334. selectOnFocus:true,
    335. resizable:true,
    336. allowBlank:false,
    337. forceSelection:true
    338. }]
    339. },{
    340. xtype:'fieldset',
    341. checkboxToggle:true,
    342. checkboxName:'queryDate',
    343. title: '按日期查询',
    344. autoHeight:true,
    345. defaults: {width: 210},
    346. collapsed: true,
    347. items :[{
    348. xtype:'datefield',
    349. fieldLabel: '日期起',
    350. name: 'dateFrom',
    351. width: 100,
    352. allowBlank: false,
    353. format:'Y/m/d'
    354. },{
    355. xtype:'datefield',
    356. fieldLabel: '日期迄',
    357. name: 'dateTo',
    358. width: 100,
    359. allowBlank: false,
    360. format:'Y/m/d'
    361. }]
    362. },{
    363. xtype:'fieldset',
    364. checkboxTog

    来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/164811/viewspace-998527/ ,如需转载,请注明出处,否则将追究法律责任。

    上一篇: ORACLE SQL语句优化技术分析(转载)
    下一篇: 没有了~
    请登录后发表评论 登录
    全部评论

    最新文章