沉睡森林@漂在北京

          本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請注明出處。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            152 隨筆 :: 4 文章 :: 114 評論 :: 0 Trackbacks
          最近一直在考慮將ext進(jìn)行標(biāo)簽處理,利用簡單的標(biāo)簽和屬性輸出ext的ui效果。將常用的ext方法進(jìn)行封裝,提供統(tǒng)一的js函數(shù)給外部調(diào)用,以此提高開發(fā)的效率。下面是一點(diǎn)嘗試的成果,需要改進(jìn)的東西還很多很多。希望自己在5月份可以多多的整理文檔,和做ext開發(fā)的朋友分享。




          代碼還是有不少的問題,不過基本的框架出來了。
          下面是jsp代碼:
          <%@ page contentType="text/html;charset=UTF-8" %>
          <%@ taglib uri="/WEB-INF/greatwall.tld" prefix="gw" %>
          <%@ include file="/commons/taglibs.jsp" %>

          <gw:html>
          <gw:head>
          <base href="${ctx}/${basePath}">
          <gw:title caption="Extjsptag TextTags Demo"/>
          <%@ include file="/commons/button-icon.jsp"  %>
          </gw:head>
             

          <gw:body>
          <gw:script>
          function func_button_submitForm(){
              queryGrid('sysUserinfoList','sysUserinfo');
          }  

          function func_button_resetForm(){
              resetForm('sysUserinfo');
          }

          function func_button_addRecord(){
              var page = new pageDefine('insert-sys_userinfo.jsp',200,600);
              page.goPage();
          }

          function func_button_updateRecord(){
              var page = new pageDefine('txn090903.do',200,600);
              page.addGridValue('userId','sysUserinfoList:userId');
              page.goPage();
          }

          function func_button_deleteRecord(){
              var page = new pageDefine('txn090906.do');
              page.addGridValues('userId','sysUserinfoList:userId');
              page.deleteRecord('確認(rèn)刪除選中的記錄?','sysUserinfoList');
          }  
          </gw:script>
               
          <gw:viewport>
                  
          <gw:block title="查詢用戶管理"   name="sysUserinfo" columns="2"  height="150" region="north" >
                      
          <gw:text name="username" fieldLabel="用戶名"   colspan="1"   />
                      
          <gw:text name="email" fieldLabel="電子郵箱" colspan="1"    />
                      
                      
          <gw:submit name="button_submitForm" handler="func_button_submitForm" />
                      
          <gw:reset name="button_resetForm" handler="func_button_resetForm" />
                  
          </gw:block>

                  
          <gw:grid name="sysUserinfoList" title="用戶管理列表" region="center" keyid="userinfoId" rownum="true" checkbox="true" url="txn090902.do"  >
                      
          <gw:button text="增加用戶管理" name="button_addRecord"  handler="func_button_addRecord"   icon="icon_add.gif"  />
                      
          <gw:button text="修改用戶管理" name="button_updateRecord" handler="func_button_updateRecord" enablerule="1" icon="icon_update.gif"  />
                      
          <gw:button text="刪除用戶管理" name="button_deleteRecord" handler="func_button_deleteRecord" enablerule="2"   icon="icon_delete.gif"  /> 
                      
                      
          <gw:cell dataIndex="userinfoId" header="用戶表ID" width="100"/>
                      
          <gw:cell dataIndex="username"  sortable="true"  header="用戶名" width="100" />
                      
          <gw:cell dataIndex="email" header="電子郵箱" width="100"/>
                  
          </gw:grid>
              
          </gw:viewport>  
          </gw:body>
          </gw:html>


          下面是現(xiàn)實(shí)后的html代碼:
          <html> 
           
          <head> 
          <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
          <meta http-equiv="Cache-Control" content="no-store"/> 
          <meta http-equiv="Pragma" content="no-cache"/> 
          <meta http-equiv="Expires" content="0"/> 
          <script src="http://localhost:8080/sie/script/ext/ext-base.js" type="text/javascript"></script> 
          <script src="http://localhost:8080/sie/script/ext/ext-all.js" type="text/javascript"></script> 
          <script src="http://localhost:8080/sie/script/ext/ext-lang-zh_CN.js" type="text/javascript"></script> 
          <link href="http://localhost:8080/sie/script/ext/resources/css/ext-all.css" type="text/css" rel="stylesheet"> 
          <script src="http://localhost:8080/sie/script/extjsptag-form.js" type="text/javascript"></script> 
          <script src="http://localhost:8080/sie/script/extjsptag-public.js" type="text/javascript"></script> 
          <script src="http://localhost:8080/sie/script/extjsptag-grid.js" type="text/javascript"></script> 
          <script src="http://localhost:8080/sie/script/extjsptag-page.js" type="text/javascript"></script> 
           
          <base href="/sie/module/yhqxgl/sys_userinfo/"> 
          <title>Extjsptag TextTags Demo</title> 
           
          <style> 
          .icon_add 
          {
            background
          : url('/sie/script/button-icon/icon_add.gif') 0 2 no-repeat   !important;
          }

          .icon_delete 
          {
            background
          : url('/sie/script/button-icon/icon_delete.gif') 0 2 no-repeat  !important;
           
          }

          .icon_update 
          {
            background
          : url('/sie/script/button-icon/icon_update.gif')  0  2 no-repeat  !important;
          }

          .icon-pub1 
          {
            background
          : url('/sie/script/button-icon/icon-pub1.gif')  0 0  no-repeat  !important;
          }
             
          </style> 
          </head> 
           
             
           
          <body> 
          <script> 
           
          var pWinCmpId = null;
           
          Ext.BLANK_IMAGE_URL 
          = 'http://localhost:8080/sie/script/ext/resources/images/default/s.gif';
          var basePath = 'http://localhost:8080/sie/module/yhqxgl/sys_userinfo/';
          var rootPath = 'http://localhost:8080/sie/';
           
          Ext.onReady(
          function() {
           
          Ext.QuickTips.init();
          Ext.form.Field.prototype.msgTarget 
          = 'qtip';
           
           
          /******************下面開始Body內(nèi)JavaScript代碼輸出************************/
           
          /********************************************/
          /******開始輸出用戶自定義JavaScript部分******/
           
          function func_button_submitForm(){
              queryGrid('sysUserinfoList','sysUserinfo');
          }
            
           
          function func_button_resetForm(){
              resetForm('sysUserinfo');
          }

           
          function func_button_addRecord(){
              
          var page = new pageDefine('insert-sys_userinfo.jsp',200,600);
              page.goPage();
          }

           
          function func_button_updateRecord(){
              
          var page = new pageDefine('txn090903.do',200,600);
              page.addGridValue('userId','sysUserinfoList:userId');
              page.goPage();
          }

           
          function func_button_deleteRecord(){
              
          var page = new pageDefine('txn090906.do');
              page.addGridValues('userId','sysUserinfoList:userId');
              page.deleteRecord('確認(rèn)刪除選中的記錄?','sysUserinfoList');
          }
            
          /******用戶自定義JavaScript部分結(jié)束********/
          /******************************************/
           
               
                  
          var sysUserinfo_bodyWidth = document.body.clientWidth ; 
          var sysUserinfo_columns = 2 * 2;
          var sysUserinfo_perWidth = sysUserinfo_bodyWidth/sysUserinfo_columns;
           
           
          var sysUserinfo = new Ext.form.FormPanel({
            region:'north',
            buttonAlign:'center',frame:
          true,layout:'table',
            name:'sysUserinfo',id:'sysUserinfo',height:
          150,title:'查詢用戶管理',
            layoutConfig: 
          {columns:sysUserinfo_columns},
            defaults:
          {border:false,layout:'form',frame:false,labelAlign:'right',labelWidth:75,width:sysUserinfo_bodyWidth ,height:30}
          }
          );
           
                      
          sysUserinfo.add(
          {
            name:'sysUserinfo_item_username',id:'sysUserinfo_item_username',
            colspan:
          2,bodyStyle:'padding:2px',
            width:sysUserinfo_perWidth
          *2-15  , 
            items:
          {
              xtype:'textfield',name:'username',anchor:'
          100%',fieldLabel:'用戶名',id:'username'
            }

          }
          );
           
                      
          sysUserinfo.add(
          {
            name:'sysUserinfo_item_email',id:'sysUserinfo_item_email',
            colspan:
          2,bodyStyle:'padding:2px',
            width:sysUserinfo_perWidth
          *2-15  , 
            items:
          {
              xtype:'textfield',name:'email',anchor:'
          100%',fieldLabel:'電子郵箱',id:'email'
            }

          }
          );
           
                      
                      
          sysUserinfo.addButton(
          {xtype:'button',name:'button_submitForm',handler:func_button_submitForm,text:'確  定',type:'submit',id:'button_submitForm'});
           
                      
          sysUserinfo.addButton(
          {xtype:'button',name:'button_resetForm',handler:func_button_resetForm,text:'重  置',type:'reset',id:'button_resetForm'});
           
                  
           
           
           
          sysUserinfo.on(
          "bodyresize"function(){
            
          var _bodyWidth = document.body.clientWidth ; 
            
          var sysUserinfo_columns = 2 * 2;
            
          var _perWidth = _bodyWidth/sysUserinfo_columns;
            sysUserinfo.getComponent(
          "sysUserinfo_item_username").setWidth(_perWidth * 2-15);
            sysUserinfo.getComponent(
          "sysUserinfo_item_email").setWidth(_perWidth * 2-15);
          }
          );
           
           
                  
                      
                      
                       
                      
                      
                      
                      
                  
          var sysUserinfoList_grid_record = Ext.data.Record.create([
            
          {name:'userinfoId',type:'string'},
            
          {name:'username',type:'string'},
            
          {name:'email',type:'string'}
          ]);
           
          var sysUserinfoList_grid_store = new Ext.data.Store({
            proxy : 
          new Ext.data.HttpProxy({url : 'http://localhost:8080/sie/txn090902.do'}),
            reader : new Ext.data.JsonReader({root : 'result',totalProperty : 'totalCount',id : 'userinfoId'}, sysUserinfoList_grid_record)
          }
          );
           
          var sysUserinfoList_grid_sm = new Ext.grid.CheckboxSelectionModel({dataIndex : 'userinfoId'});
          var sysUserinfoList_grid_rownum = new Ext.grid.RowNumberer();
          var sysUserinfoList_grid_cm = new Ext.grid.ColumnModel([
            sysUserinfoList_grid_sm,
            sysUserinfoList_grid_rownum,
            
          {dataIndex:'userinfoId',width:100,type:'string',header:'用戶表ID'},
            
          {dataIndex:'username',sortable:true,width:100,type:'string',header:'用戶名'},
            
          {dataIndex:'email',width:100,type:'string',header:'電子郵箱'}
          ]);
           
          var displayMsg = '顯示第【<b><font color=red>{0}</font></b>】條至第【<b><font color=red>{1}</font></b>】條 / 共【<b><font color=red>{2}</font></b>】條記錄';
          var sysUserinfoList_grid_bbar = new Ext.PagingToolbar({
            store: sysUserinfoList_grid_store,
            displayMsg: displayMsg,
            emptyMsg: '沒有信息',
            pageSize: 
          10,
            displayInfo: 
          true,
            items: ['
          &nbsp;&nbsp;&nbsp;&nbsp;每頁顯示數(shù)', new Ext.form.ComboBox({
              store: 
          new Ext.data.SimpleStore({
                fields: ['abbr', 'state'],
                data: [[
          1010], [1515], [2020], [3030], [4040], [6060], [8080], [100100]]
              }
          ),
              width: 
          50,displayField: 'state',typeAhead: true,mode: 'local',value: 10,triggerAction: 'all',selectOnFocus: true,
              listeners: 
          {
                change: 
          {
                  fn: 
          function(box, newValue, oldValue){
                    sysUserinfoList_grid_bbar_change_PageSize(newValue);
                  }

                }
          ,
                select: 
          {
                  fn: 
          function(combo, value){
                    
          //sysUserinfoList_grid_bbar_change_PageSize(combo.getValue());
                  }

                }

              }

            }
          )]
          }
          );
           
          function sysUserinfoList_grid_bbar_change_PageSize(newValue){
            sysUserinfoList_grid_bbar['pageSize']
          =newValue;
            sysUserinfoList.store.reload(
          { params : { start : 0, limit : newValue } });
          }
          ;
           
          var sysUserinfoList_grid_tbar = [
            
          {xtype:'button',name:'button_addRecord',cls:'x-btn-text-icon',handler:func_button_addRecord,icon:'http://localhost:8080/sie/script/button-icon/icon_add.gif',text:'增加用戶管理',type:'button',id:'button_addRecord'},'-',
            {xtype:'button',name:'button_updateRecord',cls:'x-btn-text-icon',disabled:true,handler:func_button_updateRecord,icon:'http://localhost:8080/sie/script/button-icon/icon_update.gif',text:'修改用戶管理',type:'button',id:'button_updateRecord'},'-',
            {xtype:'button',name:'button_deleteRecord',cls:'x-btn-text-icon',disabled:true,handler:func_button_deleteRecord,icon:'http://localhost:8080/sie/script/button-icon/icon_delete.gif',text:'刪除用戶管理',type:'button',id:'button_deleteRecord'}
          ];
           
          var  sysUserinfoList = new Ext.grid.GridPanel({
            viewConfig: 
          { forceFit: true },
            ds :  sysUserinfoList_grid_store,
            cm : sysUserinfoList_grid_cm,
            selModel : 
          new Ext.grid.RowSelectionModel(),loadMask : true,
            tbar:sysUserinfoList_grid_tbar,
            bbar :  sysUserinfoList_grid_bbar,
            bodyStyle:'width:
          100%',
            url:'http:
          //localhost:8080/sie/txn090902.do',
            name:'sysUserinfoList',region:'center',title:'用戶管理列表',iconCls:'icon-pub1',id:'sysUserinfoList'
          }
          );
           
          sysUserinfoList.on(
          "cellclick"function(){
            
          var records = sysUserinfoList.getSelections();
            
          if (!records || records.length == 0{
              Ext.getCmp(
          "button_updateRecord").disable();
              Ext.getCmp(
          "button_deleteRecord").disable();
            }

            
          if (records.length == 1{
              Ext.getCmp(
          "button_updateRecord").enable();
              Ext.getCmp(
          "button_deleteRecord").enable();
            }

            
          if (records.length > 1{
              Ext.getCmp(
          "button_updateRecord").disable();
              Ext.getCmp(
          "button_deleteRecord").enable();
            }

          }
          );
           
              
          var viewport = new Ext.Viewport({
            layout:'border',
            items:[sysUserinfo,sysUserinfoList]
          }
          );
            
           
          /******************Body內(nèi)JavaScript代碼輸出結(jié)束************************/
          }
          );

          </script> 
          </body> 
           
          </html> 
          posted on 2009-05-04 16:49 王總兵 閱讀(1890) 評論(5)  編輯  收藏 所屬分類: Ext

          評論

          # re: ext的grid和queryForm的整合處理 2009-05-04 17:31 陽衡鋒
          ext 好像有一個taglib吧 http://www.exttld.com/  回復(fù)  更多評論
            

          # re: ext的grid和queryForm的整合處理 2009-05-04 17:42 王兵
          @陽衡鋒
          確實(shí)有一個 并且還有不少
          我希望我的這個標(biāo)簽可以和一部分的后臺程序結(jié)合起來使用,完成用戶權(quán)限的控制。  回復(fù)  更多評論
            

          # re: ext的grid和queryForm的整合處理 2009-05-05 13:09 tee
          一直在想,那么多人那么痛苦的要把b/s整成c/s,大量精力都花在了UI而不是業(yè)務(wù)邏輯上,何必呢?  回復(fù)  更多評論
            

          # re: ext的grid和queryForm的整合處理 2009-05-05 13:40 王兵
          @tee
          業(yè)務(wù)邏輯其實(shí)是核心的東西
          但是架構(gòu)師是不需要關(guān)心具體的業(yè)務(wù)邏輯
          我們公司有自己的產(chǎn)品 自己的平臺、UI、快速開發(fā)環(huán)境等等
          這些都和業(yè)務(wù)沒關(guān)系   回復(fù)  更多評論
            

          # re: ext的grid和queryForm的整合處理[未登錄] 2009-05-07 09:27 陳亮
          我認(rèn)為用模板比用標(biāo)簽封裝方便,標(biāo)簽調(diào)試起來太麻煩  回復(fù)  更多評論
            

          主站蜘蛛池模板: 威海市| 恭城| 水富县| 来安县| 绥化市| 靖远县| 昭通市| 马公市| 体育| 托克逊县| 吐鲁番市| 同仁县| 德庆县| 龙游县| 定襄县| 韩城市| 辰溪县| 偏关县| 隆林| 桐乡市| 黄陵县| 柳林县| 宜宾市| 文化| 沛县| 遂平县| 云南省| 三都| 托克托县| 罗山县| 泰安市| 西华县| 潜江市| 类乌齐县| 白山市| 正镶白旗| 东丽区| 南木林县| 达尔| 西昌市| 天长市|