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

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

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

    efa's blog

    以用戶角度出發(fā),你就已經(jīng)成功一半了.

    導(dǎo)航

    <2005年8月>
    31123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

    統(tǒng)計(jì)

    常用鏈接

    留言簿(18)

    我參與的團(tuán)隊(duì)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    Bi report

    dba

    info security

    other

    perl

    php

    python

    tech blogs

    tech websites

    最新隨筆

    搜索

    積分與排名

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    也來(lái)介紹一下 extremeTable


    1、何為 extremeTable,又一個(gè)開(kāi)源taglib
          extremeTable,開(kāi)源的jsp 自定義標(biāo)簽,以表格的形式顯示數(shù)據(jù),當(dāng)前最新版本為 1.0.1-M1.
    它是一個(gè)類似display tag,valueList 等開(kāi)源產(chǎn)品.
    homepage: http://extremecomponents.org/
    download: http://sourceforge.net/projects/extremecomp/

    開(kāi)源產(chǎn)品作者:
    Jeff Johnston ,現(xiàn)居住美國(guó),圣路易斯.
                    六年web應(yīng)用軟件開(kāi)發(fā)經(jīng)驗(yàn),eXtremeComponents最初的創(chuàng)建者. 負(fù)責(zé)設(shè)計(jì)及大部分的編碼。

    其它還包括Paul Horn ,eXtremeTree的技術(shù)設(shè)計(jì), 以及大部分的編碼;
    Dave Goodin,Brad Parks等.

    主要特色
    1、導(dǎo)出EXCEL以及pdf無(wú)需再另寫(xiě)jsp(這個(gè)基本與valuelist作比較,因?yàn)橐郧坝胿alueList的時(shí)候每寫(xiě)一個(gè)table都要再寫(xiě)一個(gè)excel.jsp)
    2、擴(kuò)展性比較強(qiáng),基本上想怎樣改就怎樣改,對(duì)jar影響比較少。
    3、另外據(jù)官方聲稱有以下四點(diǎn)

  • Fast ( 本人曾小測(cè)一次,三千紀(jì)錄情況下,效率基本與valuelist持平)
  • Efficient
  • Easy ( 得確很容易使用與理解加擴(kuò)展)
  • Reliable

    安裝要求
    1、Servlet 2.3 或更高
    2、 JDK 1.3.1 或更高

    最小的Jars需求
    1、commons-beanutils 1.6
    2、commons-collections 3.0
    3、 commons-lang 2.0
    4、 commons-logging 1.0.4
    5、 standard 1.0.2

    PDF 導(dǎo)出要用到的包:
    1、 avalon-framework 4.0
    2、batik 1.5-fop-0.20-5
    3、 fop 0.20.5
    4、 xalan 2.5.1
    5、 xercesImpl 2.6.1
    6、 xml-apis 2.0.2
    XLS 導(dǎo)出要用到的包:
    1、 poi-2.5.1.jar


    2、安裝與測(cè)試

    下載解壓到的主要文件包括

    [1]src源文件
    [2]extremecomponents.jar以及其它所依賴的包

    [3]tld文件
    extremecomponents.tld

    [4]一組默認(rèn)樣式及圖片
    extremecomponents.css

    [5]用以校驗(yàn)安裝的測(cè)試頁(yè)面
    test.jsp

    [6]doc文檔,比較詳細(xì)

    快速配置安裝
    web app目錄結(jié)構(gòu)
    /ROOT
         /WEB-INF/web.xml
            /tld/extremecomponents.tld
               /lib
               /classes/extremecomponents.properties
                       [extremecomponents.properties文件可到source\org\extremecomponents\table\core\中得到]
          /images/*.jpg [一組默認(rèn)樣式及圖片]
          /css/extremecomponents.css
          /test.jsp
          /index.jsp [用于學(xué)習(xí)以及擴(kuò)展測(cè)試用代碼請(qǐng)見(jiàn)下]
        

    web.xml 配置
    包括taglib uri 定義以及導(dǎo)出文件filter,由于只是手板功夫,這里就略過(guò)了,相關(guān)代碼如下:

    <taglib>
    <taglib-uri>/tld/extremecomponents</taglib-uri>
    <taglib-location>/WEB-INF/tld/extremecomponents.tld</taglib-location>
    </taglib>

    <filter>
    <filter-name>eXtremeExport</filter-name>
    <filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>eXtremeExport</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>


    配置好所有后,開(kāi)tomcat,測(cè)試瀏覽http://your_web_app/test.jsp,看到

    Congratulations!! You have successfully configured eXtremeTable!
    恭喜你,這表示安裝成功!


    3、動(dòng)手學(xué)習(xí)這個(gè)taglib
    建index.jsp頁(yè)面,修改代碼如下

    <%@ page contentType="text/html;charset=GBK"%>
    <%@ page import="java.util.*"%>
    <%@ taglib uri="/tld/extremecomponents" prefix="ec" %>
    <!-- 在本頁(yè)要用到j(luò)stl-->
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <!--使用include的方式-->
    <link rel="stylesheet" type="text/css" href="<c:url value="/extremecomponents.css"/>">

    <%
        List goodss 
    = new ArrayList();
        
    for (int i = 1; i <= 10; i++)
        
    {
            Map goods 
    = new java.util.HashMap();
            goods.put(
    "code""A00"+i);
            goods.put(
    "name""面包"+i);
            goods.put(
    "status""A:valid");
            goods.put(
    "born"new Date());
            goodss.add(goods);
        }

        request.setAttribute(
    "goodss", goodss);
    %>
    <ec:table
     collection
    ="goodss"
        action
    ="${pageContext.request.contextPath}/test.jsp"
        imagePath
    ="${pageContext.request.contextPath}/images/*.gif"
        cellpadding
    ="1"
        title
    ="my bread">
    <ec:column property="code"/>
    <ec:column property="name"/>
    <ec:column property="status"/>
    <ec:column property="born" cell="date" format="yyyy-MM-dd"/>
    </ec:table>



    效果如下:
    ec1.jpg


    [1] 1.0.1-M1 版支持國(guó)際化
    修改web.xml文件增加

    <context-param>
       
    <param-name>extremecomponentsResourceBundleLocation</param-name>
       
    <param-value>com.itorgan.tags.extreme.extremetableResourceBundle</param-value>
    </context-param>



    意指到 com.itorgan.tags.extreme 下找 extremetableResourceBundle_[language]_[country].properties 文件

    extremetableResourceBundle_en_US.properties代碼如下
    table.statusbar.resultsFound={0} results found, displaying {1} to {2}
    table.statusbar.noResultsFound=There were no results found.
    table.toolbar.showAll=Show All

    extremetableResourceBundle_zh_CN.properties如下.
    table.statusbar.resultsFound={0} \u6761\u7EAA\u5F55\u7B26\u5408\u6761\u4EF6, \u73B0\u5728\u662F\u7B2C {1} \u81F3 {2} \u6761\u7EAA\u5F55
    table.statusbar.noResultsFound=\u6CA1\u6709\u8981\u67E5\u8BE2\u7684\u7EAA\u5F55\u3002
    table.toolbar.showAll=\u6240 \u6709

    補(bǔ)充:中文 - > Unicode編碼 可通過(guò)反編譯class文件或用native2ascii命令得到 。

    然后在table標(biāo)簽中增加locale屬性即可切換

    <ec:table
        ………………
        ………………
        ………………
        locale
    ="en_US"
    >

    <ec:table
        ………………
        ………………
        ………………
        locale
    ="zh_CN"
    >


    [2] 保留table的上一次狀態(tài)
          是指,不管跳轉(zhuǎn)到另一個(gè)后再返回,extremeTable會(huì)將之前的Filter,Sort參數(shù)保存到session中,以至返回看到的頁(yè)面還是之前的狀態(tài).
    實(shí)現(xiàn)操作方法:
    修改extremecomponents.properties文件
    table.useSessionFilterSortParam=foo
    saveFilterSort="true" 注意:saveFilterSort="true"不能在properties文件中配置,只能在頁(yè)面中設(shè)

     <ec:table
        ……………………
        saveFilterSort
    ="true"
    /ec:table>
    <a href="1.jsp">跳到</a>

    新建一頁(yè)面用于跳轉(zhuǎn)的頁(yè)面 1.jsp
    代碼為

    <a href="test.jsp?foo=true">Back</a>


    [3] 樣式修改
    基本的HTML結(jié)構(gòu)

    <div class="eXtremeTable" >
    <table border="0"  cellpadding="0"  cellspacing="0"  width="100%" >
        
    <tr>
            
    <td class="title" ><span><!--標(biāo)題--></span></td>
            
    <td align="right" >
            
    <table border="0"  cellpadding="0"  cellspacing="1"  class="toolbar" >
                
    <tr>
          
    <form name="pres_toolbar"  action="/extremesite/public/demo/presidents.jsp" >
                
    <!--工具欄,包括上一頁(yè),下一頁(yè)以及導(dǎo)出-->
                
    </tr>
                
    <tr> 
          
    </form>
                
    </tr>
            
    </table>
            
    </td>
        
    </tr>
    </table>

    <table id="pres"  border="0"  cellspacing="2"  cellpadding="0"  width="100%"  class="tableRegion" >
        
    <tr>
            
    <td colspan="6" >
            
    <table border="0"  cellpadding="0"  cellspacing="0"  width="100%" >
                
    <tr>
                    
    <td class="statusBar" >43 results found, displaying 1 to 12 </td>
                    
    <td class="filterButtons" ></td>
                
    </tr>
            
    </table>
            
    </td>
        
    </tr>        

    <form name="pres_filter"  action="/extremesite/public/demo/presidents.jsp" >
        
    <tr class="filter"  id="filter" >
            
    <!--過(guò)濾條件的input框-->
        
    </tr>
    </form>
        
    <tr>
            
    <!--tableHead-->
        
    </tr>
        
    <tbody class="tableBody" >
        
    <tr>
            
    <!--column-->
        
    </tr>
        
    </tbody>
    </table>
    </div>


    extremeTable支持樣式快速切換.可自定的樣式包括column 的td以及table的一些屬性,例如cellpadding等,
    另本人發(fā)現(xiàn),在properties中如下設(shè)置tableHeader的樣式是不行的.不知道是否一個(gè)BUG
    table.headerClass=itoTableHeader
    table.headerSortClass=itoTableHeaderSort

    只能繼承一個(gè)HeaderCell

    public class HeaderCell extends org.extremecomponents.table.cell.HeaderCell
    {
        
    public final static String TABLE_HEADER = "itoTableHeader";
        
    public final static String TABLE_HEADER_SORT = "itoTableHeaderSort";

    新的樣式代碼:

    <LINK REL="stylesheet" HREF="<c:url value="/style.css"/>" TYPE="text/css">
     <ec:table
     collection="goodss"
        action="${pageContext.request.contextPath}/test.jsp"
        imagePath="${pageContext.request.contextPath}/images/*.gif"
        cellpadding="1"
        title="my bread"
        saveFilterSort="true"
        locale="zh_CN"
    >
    <ec:column property="code" title="編號(hào)" width="100" styleClass="GridTd"/>
    <ec:column property="name" title="名稱" width="200" styleClass="GridTd"/>
    <ec:column property="status" title="狀態(tài)" width="80" styleClass="GridTd"/>
    <ec:column property="born" title="生產(chǎn)日期" width="100" cell="date" format="yyyy-MM-dd" styleClass="GridTd"/>
    </ec:table>

    效果見(jiàn)下:
    ec[2].jpg

    [4] 實(shí)現(xiàn) table width 自動(dòng)累加
    原來(lái)的extremeTable 寬度要自己set。不會(huì)自動(dòng)能過(guò)下面的column累加。
    本人作了個(gè)修改以達(dá)到自動(dòng)累加,省得自己加寫(xiě)上去:
    查看htmlView.java 兩處地方 
    toolbarPlacement
    tableStart可見(jiàn)兩處地方要修改的


    [5] custom cell
    在properties文件中我們可觀察到:

    table.cell_=display
    table.cell_currency=org.extremecomponents.table.cell.NumberCell
    table.cell_number=org.extremecomponents.table.cell.NumberCell
    table.cell_display=org.extremecomponents.table.cell.DisplayCell
    table.cell_date=org.extremecomponents.table.cell.DateCell

    當(dāng) column 默認(rèn)使用org.extremecomponents.table.cell.DisplayCell

    public class DisplayCell extends BaseCell {

        
    public String html() {
            HtmlBuilder html 
    = new HtmlBuilder();

            html.append(startTD());

            Object value 
    = column.getValue();
            
    if (value != null && StringUtils.isNotEmpty(value.toString())) {
                html.append(value);
            }
     else {
                html.append(
    "&nbsp;");
            }


            html.append(endTD());

            
    return html.toString();
        }

    }


    ec已其它c(diǎn)ell
    日期格式化: cell = " date " format = " yyyy-MM-dd "
    數(shù)字格式化: cell="currency" format="###,###,##0.00"


    另外,extremeTable支持自定義cell
    在這里我以一個(gè)簡(jiǎn)單的例子[以input框的形式出現(xiàn)] 說(shuō)明如何實(shí)現(xiàn)這一方便的擴(kuò)展

    public class DemoInput extends BaseCell
    {
          
    public String html()
        
    {
            Integer rowNum 
    = rowcount;
            HtmlBuilder html 
    = new HtmlBuilder();
            html.append(startTD());
            Object value 
    = column.getValue();
            HtmlBuilder input 
    = new HtmlBuilder();
            input.input(
    "text");
            input.name(column.getProperty() 
    + "_" + rowNum);
            input.value(value.toString());
            input.close();
            html.append(input.toString());
            html.append(endTD());
            
    return html.toString();
        }

    }


    properties文件增加

    table.cell_demoInput =org.extremecomponents.table.cell.DemoInput 

    jsp代碼

    <ec:column property="code" title="編號(hào)" width="100" cell="demoInput" styleClass="GridTd"/>

    效果顯示為
    當(dāng)然這只是一個(gè)簡(jiǎn)單的demo以說(shuō)明如何自定義cell
    如上面你可以簡(jiǎn)單的實(shí)現(xiàn)同樣功能

    <ec:column property="code" title="編號(hào)" width="100" styleClass="GridTd">
    <input type="text" value="${goodss.code}" name="code_${ROWCOUNT}">
    </ec:column>



    [6]Extended Attributes
    新版本支持Extended Attributes,方便了用戶擴(kuò)展,記得0.9版本時(shí)還要我修改N個(gè)地方,現(xiàn)在為table,column增加attribute方便多了.
    為table增加一個(gè)height的屬性

    public class TableTag extends org.extremecomponents.table.tag.TableTag
    {
        
    //div 的高度
        private String height;

        
    public String getHeight()
        
    {
            
    return height;
        }


        
    public void setHeight(String height)
        
    {
            
    this.height = height;
        }


        
    public void addExtendedAttributes(Attributes attributes)
        
    {
            attributes.addAttribute(
    "height", getHeight());
        }


        
    /**
         * set the new attribuer to null - by ito
         
    */

        
    public void release()
        
    {
            super.release();
            height 
    = null;
        }

    }

    然后就可以通過(guò)
    model.getTableHandler().getTable().getAttribute("height")取得這個(gè)值.可以方便擴(kuò)展.

    [7] 解決excel中文問(wèn)題
    繼承XlsView.java

        private void body(BaseModel model, Column column, boolean isFirstColumn, boolean isLastColumn) {
          
    //原來(lái)的代碼略
            hssfCell.setEncoding(HSSFCell.ENCODING_UTF_16); //解決中文亂碼
    //原來(lái)的代碼略
            
        }


        
    private void createHeader(BaseModel model) {
           
    //原來(lái)的代碼略
            hssfCell.setEncoding(HSSFCell.ENCODING_UTF_16); //解決中文亂碼
    //原來(lái)的代碼略
            
       }


    [8] 解決pdf中文問(wèn)題
    幫POF注冊(cè)中文字體,再修改export view即可解決

    [9] Pagination

    [10] 其它亮點(diǎn)
    A sortable 與 exportable 屬性 ,分別指可否排序,可否導(dǎo)出. 值為 false/true
    B 可以直接在<ec:column></e:column>中加html代碼.
        并可用{collectionName.objectName}類似的語(yǔ)法取得當(dāng)前object的成員變量值
    C  ${ROWCOUNT}可取當(dāng)前row num,是指以1開(kāi)始計(jì)算 
    D  ec另一亮點(diǎn)就幫我們寫(xiě)好了form ,如上代碼:
          <ec:form name="mainform" action="goods.do"> </ec:form> 設(shè)置form name以及action

    參考文檔
    http://extremecomponents.org/extremesite/public/documentation.jsp

  • posted on 2005-08-09 19:56 一凡@ITO 閱讀(20580) 評(píng)論(102)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲jjzzjjzz在线播放| 亚洲熟妇成人精品一区| 爱爱帝国亚洲一区二区三区| 中文字幕永久免费| 免费观看成人毛片a片2008| 亚洲国产精品综合久久一线| 老色鬼久久亚洲AV综合| 久久精品熟女亚洲av麻豆| 免费在线观看一级片| 热久久精品免费视频| 亚洲av永久无码制服河南实里| 久久精品国产亚洲av天美18| 无码av免费网站| 内射无码专区久久亚洲| 亚洲免费网站在线观看| 91精品成人免费国产| 日本高清免费中文字幕不卡| 亚洲一本综合久久| 精品国产日韩亚洲一区91| 亚欧人成精品免费观看| 亚洲精品国产字幕久久不卡| 亚洲aⅴ无码专区在线观看 | 中文字幕在线观看免费| 性感美女视频免费网站午夜| 国产∨亚洲V天堂无码久久久| 久久亚洲色WWW成人欧美| h视频在线观看免费网站| 亚洲精品无码不卡在线播放HE| 亚洲久热无码av中文字幕| 99免费观看视频| 亚洲欧洲成人精品香蕉网| 亚洲日韩精品国产一区二区三区| 亚洲视频在线观看免费| 国产亚洲老熟女视频| 国产亚洲精品美女久久久久| 91免费精品国自产拍在线不卡| 亚洲伦另类中文字幕| 成人免费777777被爆出| 亚洲国产一级在线观看| 亚洲精品av无码喷奶水糖心| 无码日韩人妻av一区免费|