開元表格框架extremeTable
開元taglib ?extremeTable
(轉(zhuǎn)載)
1、何為 extremeTable,又一個開源taglib
????? extremeTable,開源的jsp 自定義標(biāo)簽,以表格的形式顯示數(shù)據(jù),當(dāng)前最新版本為 1.0.1-M1.
它是一個類似display tag,valueList 等開源產(chǎn)品.
homepage: http://extremecomponents.org/
download: http://sourceforge.net/projects/extremecomp/
開源產(chǎn)品作者:
Jeff Johnston ,現(xiàn)居住美國,圣路易斯.
??????????????? 六年web應(yīng)用軟件開發(fā)經(jīng)驗,eXtremeComponents最初的創(chuàng)建者. 負(fù)責(zé)設(shè)計及大部分的編碼。
其它還包括Paul Horn ,eXtremeTree的技術(shù)設(shè)計, 以及大部分的編碼;
Dave Goodin,Brad Parks等.
主要特色
1、導(dǎo)出EXCEL以及pdf無需再另寫jsp(這個基本與valuelist作比較,因為以前用valueList的時候每寫一個table都要再寫一個excel.jsp)
2、擴(kuò)展性比較強(qiáng),基本上想怎樣改就怎樣改,對jar影響比較少。
3、另外據(jù)官方聲稱有以下四點
安裝要求
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、安裝與測試
下載解壓到的主要文件包括
[1]src源文件
[2]extremecomponents.jar以及其它所依賴的包
[3]tld文件
extremecomponents.tld
[4]一組默認(rèn)樣式及圖片
extremecomponents.css
[5]用以校驗安裝的測試頁面
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ò)展測試用代碼請見下]
????
web.xml 配置
包括taglib uri 定義以及導(dǎo)出文件filter,由于只是手板功夫,這里就略過了,相關(guān)代碼如下:













配置好所有后,開tomcat,測試瀏覽http://your_web_app/test.jsp,看到
Congratulations!! You have successfully configured eXtremeTable!
恭喜你,這表示安裝成功!
3、動手學(xué)習(xí)這個taglib
建index.jsp頁面,修改代碼如下


































效果如下:
[1] 1.0.1-M1 版支持國際化
修改web.xml文件增加




意指到 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編碼 可通過反編譯class文件或用native2ascii命令得到 。
然后在table標(biāo)簽中增加locale屬性即可切換














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




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

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














































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







新的樣式代碼:

?<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="編號" 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>
效果見下:
[4] 實現(xiàn) table width?自動累加
原來的extremeTable 寬度要自己set。不會自動能過下面的column累加。
本人作了個修改以達(dá)到自動累加,省得自己加寫上去:
查看htmlView.java 兩處地方
toolbarPlacement
tableStart可見兩處地方要修改的
[5] custom cell
在properties文件中我們可觀察到:





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




























ec已其它cell
日期格式化: cell = " date " format = " yyyy-MM-dd "
數(shù)字格式化: cell="currency" format="###,###,##0.00"
另外,extremeTable支持自定義cell
在這里我以一個簡單的例子[以input框的形式出現(xiàn)] 說明如何實現(xiàn)這一方便的擴(kuò)展






















properties文件增加

jsp代碼

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



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








































然后就可以通過
model.getTableHandler().getTable().getAttribute("height")取得這個值.可以方便擴(kuò)展.
/ec:table
ec:table
[7] 解決excel中文問題
繼承XlsView.java

















[8] 解決pdf中文問題
幫POF注冊中文字體,再修改export view即可解決
[9] Pagination
[10] 其它亮點
A sortable 與 exportable 屬性 ,分別指可否排序,可否導(dǎo)出. 值為 false/true
B 可以直接在<ec:column></e:column>中加html代碼.
??? 并可用{collectionName.objectName}類似的語法取得當(dāng)前object的成員變量值
C? ${ROWCOUNT}可取當(dāng)前row num,是指以1開始計算?
D/ec:table
ec:table
?ec另一亮點就幫我們寫好了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 閱讀(3722) 評論(19) ?編輯?收藏引用收藏至365Key
評論
#?re: 也來介紹一下 extremeTable 2005-08-25 13:09 江南白衣@ITO
1.0.2 M1又出來啦,cvs里每天都有更新,很勤快的一個項目??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-08-26 12:41 Water Ye@ITO
<ec:table collection="goodss">
<ec:column property="code"/>
<ec:column property="name"/>
<ec:column property="status"/>
<ec:column property="born" cell="date" format="yyyy-MM-dd"/>
</ec:table>
如果想拿某條記錄的用什么屬性??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-08-26 23:17 laozheng126
動態(tài) 列怎么做?我的email:laozheng126@126.com??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-08-27 01:46 江南白衣@ITO
動態(tài)要未來版本才支持的功能,在他的RoadMap里面有講,1.0正式版之前會實現(xiàn)。??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-08-27 14:34 一天一點@ITO
回復(fù):
[1]使用jsp2.0 EL 語法,例如${presidents.lastName} 可以取得當(dāng)前列.
它應(yīng)該是request或sessoin這類的對象.setAttribute()的
Added TableTag var attribute. Used (optionally) as the name of
據(jù)了解,最新版本1.0.2-M1已修復(fù)這種難以理解的寫法:
"Added TableTag var attribute. Used (optionally) as the name of the variable to hold the current bean. "
TableTag var attribute(completed for 1.0.2-M1 release) If you would prefer to not have each bean placed in the pageScope with the collection attribute value, as the table is iterating over the body, then you could use the optional var attribute. Some users said that overloading the collection attribute was not flexible enough.
具體使用請見本人對extremeTable跟進(jìn)BLOG頁
[2]roadmap中有提到動態(tài) 列的支持,"Dynamically Hide/Show columns "
另外還增加好多令人興奮不已的新元素,
期待
http://extremecomponents.org/extremesite/public/roadMap.jsp??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-08-30 19:33 kiven
請問導(dǎo)出excle文件的中文問題怎么解決阿?
我試著重新編譯xlsview.java文件但是總是通不過,哪位大俠有編譯好的提供一下好嗎?
謝謝了!??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-08-31 09:22 David
[1]繼承原類 XlsView
public class XlsView extends org.extremecomponents.table.view.XlsView
{
//其它略
private void body(BaseModel model, Column column, boolean isFirstColumn, boolean isLastColumn) {
//解決中文亂碼問題
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
}
private void createHeader(BaseModel model) {
//解決中文亂碼問題
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
}
//其它略
}
[2]修改extremecomponents.properties
table.view_xls=com.itorgan.tags.extreme.XlsView??回復(fù)??
#?關(guān)注開源項目,簡化開發(fā)流程[TrackBack] 2005-09-08 23:57 Gavin_Ellen
Ping Back來自:blog.csdn.net??查看原文??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-10-14 01:06 anthens
解決pdf中文問題
幫POF注冊中文字體,再修改export view即可解決
-----------------------------
能不能給小弟詳細(xì)解釋一下,我試了好多次,都是失敗告終!
大俠如能指點一二,不勝感激!
我的郵箱:anthens@163.com??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-10-14 09:13 David
最近忙些東西,關(guān)于這方面的介紹可能要等閑了的時候,如果不急的話再注意吧 :)??回復(fù)??
#?為什么我試了, 不成功 2005-12-02 14:09 Jude
按照上面的方法, 提示如下, 高手幫幫忙
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: TableTag Problem: java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isNotBlank(Ljava/lang/String;)Z
at org.extremecomponents.table.tag.TableTagUtils.getPropertiesLocation(TableTagUtils.java:270)
at org.extremecomponents.table.tag.TableTag.doStartTag(TableTag.java:490)
at org.apache.jsp.test_jsp._jspx_meth_ec_table_0(test_jsp.java:430)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:358)
??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-12-02 16:22 xuruchao
common-lang2.0沒有加入classpath??回復(fù)??
#?re: 也來介紹一下 extremeTable 2005-12-03 19:21 一天一點@ITO
"javax.servlet.ServletException: TableTag Problem: java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isNotBlank(Ljava/lang/String;)Z "
提示得很清楚:)
??回復(fù)??
#?re: 也來介紹一下 extremeTable 2006-04-21 14:18 david.turing
efa,1.0.1M4的tld定義好像跟以前版本不一樣
<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>
中,collection好像變成items了??回復(fù)??
#?re: 也來介紹一下 extremeTable 2006-04-21 15:15 davidxu
好久的版本號已經(jīng)改了, 好象是 1.0.1-M2 吧
http://www.aygfsteel.com/davidxu/archive/2005/08/27/11316.aspx
"collection attribute 不再贊成使用,可以使用tableId, items, and var 取而代之
"??回復(fù)??
#?re: 也來介紹一下 extremeTable 2006-04-29 10:00 zhuiyun
@David
請問extremecomponents.properties在哪能找到,是要自己定義嗎?初接觸extremecomponents,還望指教!
??回復(fù)??
#?re: 也來介紹一下 extremeTable 2006-04-29 10:31 zhuiyun
@David
extremecomponents.properties 是否需要在web.xml中引用??回復(fù)??
#?re: 也來介紹一下 extremeTable 2006-04-29 15:52 davidxu
@zhuiyun
1 在src目錄下應(yīng)該可以找到
2 是的,配置大概是這樣子
<context-param>
<param-name>extremecomponentsPreferencesLocation</param-name>
<param-value>/extremetable.properties</param-value>
</context-param>??回復(fù)??
#?re: 也來介紹一下 extremeTable2006-09-29 18:10 fdse
竟然連列寬都不能調(diào)節(jié)??回復(fù)??
posted on 2006-11-03 10:43 hardson 閱讀(785) 評論(0) 編輯 收藏 所屬分類: 開源框架