<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 41,  comments - 8,  trackbacks - 0
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC 
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
    > 
           
    <hibernate-mapping>
           
    <class name="com.model.Order"  table="t_order" lazy="false">
               
    <id name="orderId" column="OrderId">
                   
    <generator class="uuid.hex" />
               
    </id>
               
    <property name="name" column="Name" type="string" />
               
    <property name="desn" column="Desn" type="string"/>
               
    <property name="booktime" column="Booktime" type="string"/>
               
    <property name="company" column="Company" />
               
    <many-to-one lazy="false" name="custom" column="CustomId" class="com.model.Customer" />
           
    </class>
       
    </hibernate-mapping>        CUSTOM.XML
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC 
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
    > 
       
    <hibernate-mapping>
           
    <class name="com.model.Custom"  table="t_custom" lazy="false">
               
    <id name="customId" column="Id">
                   
    <generator class="uuid.hex" />
               
    </id>
               
    <property name="customName" column="Name" type="string" />
           
    </class>
       
    </hibernate-mapping>

            相應(yīng)的MODEL的JAVA我就不寫了,只是做個(gè)例子而已,呵呵!相應(yīng)的DAO SERVICE 我都不寫了,這個(gè)不是我討論的范圍,那么我想在頁面上顯示所有的信息,那么在OrderAction中我定義了一個(gè)getAllOrder的方法,然后通過struts2配置action讓EXTJS與服務(wù)器數(shù)據(jù)進(jìn)行數(shù)據(jù)交互。因?yàn)镋XTJS是支持JSON數(shù)據(jù)格式的,所以我用了JSON-LIB(json-lib-2.2.1-jdk15.jar)這個(gè)東東,它還依賴另外的3個(gè)包:commons-beanutils-1.7.1-20061106.jar,commons-collections-3.2.1.jar,ezmorph-1.0.4.jar。好了萬事俱備只欠東風(fēng)了,我的getAllOrder方法如下:
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.List;
    import net.sf.json.*;
    //具體的那些serivce的包引入我就省略了
    public class OrderAction extends ActionSupport
    {
       
    private static final long serialVersionUID = -5092865658281004791L;
        
    private IOrderSerivce orderSerivce;
        
    private String jsonString;//這個(gè)就是中轉(zhuǎn)站了
        private List<Order> orderList;//這個(gè)是數(shù)據(jù)鏈表
        private int totalCount;//這個(gè)是extjs用來分頁
         public String getJsonString()
        
    {
            
    return jsonString;
        }

         
    public void setJsonString(String jsonString)
        
    {
            
    this.jsonString = jsonString;
        }

        
    public int getTotalCount()
        
    {
            
    return totalCount;
        }

        
    public void setTotalCount(int totalCount)
        
    {
            
    this.totalCount = totalCount;
        }

        
    public List<Air> getOrderList()
        
    {
            
    return orderList;
        }

        
    public void setOrderList(List<Order> orderList)
        
    {
            
    this.orderList = orderList;
        }

        
    public void setOrderSerivce(OrderSerivce orderSerivce)
        
    {
            
    this.orderSerivce = orderSerivce;
        }

        
    public String getAllAir()
        
    {
            orderList 
    = orderSerivce.getOrderAll();
            
    this.setTotalCount(orderList.size());
            
            JSONArray array 
    = JSONArray.fromObject(orderList);
    //哈哈,就是在這里進(jìn)行轉(zhuǎn)換的
            this.jsonString = "{totalCount:"+this.getTotalCount()+",results:"+array.toString()+"}";
        
    return SUCCESS;
        }

    }
            接下來再是什么,哦,是的,應(yīng)該是STRUTS的配置了,哈哈
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd"
    >

    <struts>
          
    <package name="order" extends="struts-default">
    <action name="getAllOrder" class="orderAction" method="getAllOrder">
                
    <result name="success" >jsondata.jsp</result>
            
    </action>
          
    </package>
    </struts>
            好的,看到j(luò)sondata.jsp了么,這里就是要放數(shù)據(jù)的地方,看看是什么吧!
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <s:property value="jsonString" escape="false" />
            是的,就是這么簡單的一個(gè)代碼!終于要到前臺了,該露臉了,呵呵,前臺代碼最關(guān)鍵的也就是JS代碼,那么我也就只貼JS了相信大家看過后都會(huì)自己弄清楚的!
    /*
     * Ext JS Library 2.1
     * Copyright(c) 2006-2008, Ext JS, LLC.
     * licensing@extjs.com
     * 
     * http://extjs.com/license
     
    */



    Ext.onReady(
    function(){
        Ext.BLANK_IMAGE_URL 
    = 'ext/resources/images/default/s.gif'; 
        Ext.QuickTips.init();
        
    var xg = Ext.grid;
        
    //這里就是設(shè)置解析格式的地方,一定要和你的Model一樣,要不然可是什么都得不到哦~~~~
        var rd = new Ext.data.JsonReader({
                    
    //總記錄數(shù)
                    totalProperty: 'totalCount', 
                   
    //哪兒是數(shù)據(jù)的頭,可以看action里面是怎么定義數(shù)據(jù)格式的,這里就是如何解析的           
                        root: 'results', 

                    //有那些字段呢?
                    fields:[
                             
    {name:'orderId'},
                                          {name:'desn'},
                             
    {name:'booktime'},
                             
    {name:'company'},
                             
    {name:'name'},
                                
    //這里就是對custom對象進(jìn)行映射的地方                        
                                          {name:'customId' ,mapping:'custom.customId'},
                             {name:'customName',mapping:'custom.customName'}
                             ]
                                         }
    );
         
    var ds = new Ext.data.Store({
                                        proxy: 
    new Ext.data.HttpProxy
    (
    {url: 'getAllOrder.action',method:'POST'}),//Url很關(guān)鍵,我就是因?yàn)闆]配好這個(gè),POST方法很重要,你可以省略,讓你看下錯(cuò)誤也行的!耽誤了一大堆時(shí)間!
                                        reader:rd
                                    }
    );
         ds.load();
         
    var sm =new xg.CheckboxSelectionModel(); //CheckBox選擇列
         var cm =new xg.ColumnModel([
                                      
    new Ext.grid.RowNumberer(), //行號列 
                                      sm,
                                      
    {id:'orderId',header: "訂單號", dataIndex: 'name'},                           {header: "訂單時(shí)間",   dataIndex: 'booktime'},
                                      
    {header: "訂單公司", dataIndex: 'company'},
                                      
    {header:"客戶姓名",dataIndex:'customName'}
                                     ]);
                                     cm.defaultSortable 
    = true;
        
    ////////////////////////////////////////////////////////////////////////////////////////
        // OrderGrid 
        ////////////////////////////////////////////////////////////////////////////////////////

        
    var ordergrid = new xg.GridPanel({
                                      ds: ds,
                                      sm: sm, 
                                      cm: cm, 
                                      width:
    1000,
                                      height:
    500,
                                      frame:
    true,
                                      title:'Framed 
    with Checkbox Selection and Horizontal Scrolling',
                                      iconCls:'icon
    -grid',
                                      renderTo: document.body
                                     }
    );
        ordergrid.render();

    }
    );

    posted on 2008-10-02 00:37 Loy Fu 閱讀(4009) 評論(0)  編輯  收藏 所屬分類: ext
    主站蜘蛛池模板: 五月婷婷亚洲综合| 麻豆国产人免费人成免费视频| 亚洲精品国产电影| 麻豆91免费视频| 亚洲精品偷拍视频免费观看| 国产亚洲一卡2卡3卡4卡新区 | 亚洲美女激情视频| 午夜不卡久久精品无码免费 | 久久影视综合亚洲| 国产A∨免费精品视频| 国产亚洲精品成人AA片新蒲金| 国内精品99亚洲免费高清| 国产成人精品日本亚洲专区61| 中文字幕不卡免费视频| 狠狠色伊人亚洲综合成人| 久久青草免费91线频观看不卡| 中文字幕亚洲色图| 一二三四在线观看免费高清中文在线观看 | 一个人免费观看www视频在线| 亚洲色偷精品一区二区三区| 男女啪啪永久免费观看网站| 四虎一区二区成人免费影院网址 | 成人A级毛片免费观看AV网站| 蜜桃传媒一区二区亚洲AV| 亚洲日韩在线观看免费视频| 13小箩利洗澡无码视频网站免费| 亚洲成年轻人电影网站www | 中文字幕无码一区二区免费| 亚洲色av性色在线观无码| 最好免费观看韩国+日本| 色爽黄1000部免费软件下载| 亚洲国产成人一区二区三区| 巨胸喷奶水视频www网免费| 九九热久久免费视频| 亚洲另类古典武侠| 亚洲国产精品自在拍在线播放| 真实国产乱子伦精品免费| 亚洲av无码专区在线电影天堂| 亚洲精品无码MV在线观看| 99在线视频免费观看视频| 人人公开免费超级碰碰碰视频 |