extremeTable 中文说明

extremeTable 中文说明

silver6 | 30 八月, 2005 18:43

1、何为 extremeTable,又一个开源taglib
extremeTable,开源的jsp 自定义标签,以表格的形式显示数据,当前最新版本为 1.0.1-M1.
它是一个类似display tag,valueList 等开源产品.
homepage: http://extremecomponents.org/
download: http://sourceforge.net/projects/extremecomp/

开源产品作者:
Jeff Johnston ,现居住美国,圣路易斯.
六年web应用软件开发经验,eXtremeComponents最初的创建者. 负责设计及大部分的编码。

其它还包括Paul Horn ,eXtremeTree的技术设计, 以及大部分的编码;
Dave Goodin,Brad Parks等.

主要特色
1、导出EXCEL以及pdf无需再另写jsp(这个基本与valuelist作比较,因为以前用valueList的时候每写一个table都要再写一个excel.jsp)
2、扩展性比较强,基本上想怎样改就怎样改,对jar影响比较少。
3、另外据官方声称有以下四点

Fast ( 本人曾小测一次,三千纪录情况下,效率基本与valuelist持平) Efficient Easy ( 得确很容易使用与理解加扩展) 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 导出要用到的包:
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 导出要用到的包:
1、 poi-2.5.1.jar

2、安装与测试

下载解压到的主要文件包括

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

[3]tld文件
extremecomponents.tld

[4]一组默认样式及图片
extremecomponents.css

[5]用以校验安装的测试页面
test.jsp

[6]doc文档,比较详细

快速配置安装
web app目录结构
/ROOT
  /WEB-INF/web.xml
 /tld/extremecomponents.tld
/lib
/classes/extremecomponents.properties
[extremecomponents.properties文件可到sourceorgextremecomponentstablecore中得到]
 /images/*.jpg [一组默认样式及图片]
 /css/extremecomponents.css
 /test.jsp
 /index.jsp [用于学习以及扩展测试用代码请见下]

web.xml 配置
包括taglib uri 定义以及导出文件filter,由于只是手板功夫,这里就略过了,相关代码如下:

None.gif < taglib >
None.gif < taglib-uri > /tld/extremecomponents taglib-uri>
None.gif<taglib-location>/WEB-INF/tld/extremecomponents.tldtaglib-location>
None.giftaglib>

None.gif < filter >
None.gif < filter-name > eXtremeExport filter-name>
None.gif<filter-class>org.extremecomponents.table.filter.ExportFilterfilter-class>
None.giffilter>
None.gif<filter-mapping>
None.gif<filter-name>eXtremeExportfilter-name>
None.gif<url-pattern>/*url-pattern>
None.giffilter-mapping>
None.gif


配置好所有后,开tomcat,测试浏览http://your_web_app/test.jsp,看到

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


3、动手学习这个taglib
建index.jsp页面,修改代码如下

None.gif @ page contentType="text/html;charset=GBK"
None.gif@ page import="java.util.*"
None.gif@ taglib uri="/tld/extremecomponents" prefix="ec"
None.gif 在本页要用到jstl--&gt
None.gif@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
None.gif使用include的方式--&gt
None.gif<link rel="stylesheet" type="text/css" href=""/extremecomponents.css"/>">
None.gif
None.gif
None.gif List goodss = new ArrayList();
None.giffor (int i = 1; i 10; i++)
ExpandedBlockStart.gifContractedBlock.gifdot.gif{
InBlock.gif Map goods = new java.util.HashMap();
InBlock.gif goods.put("code", "A00"+i);
InBlock.gif goods.put("name", "面包"+i);
InBlock.gif goods.put("status", "A:valid");
InBlock.gif goods.put("born", new Date());
InBlock.gif goodss.add(goods);
ExpandedBlockEnd.gif }

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



效果如下:
ec1.jpg


[1] 1.0.1-M1 版支持国际化
修改web.xml文件增加

None.gif < context-param >
None.gif < param-name > extremecomponentsResourceBundleLocation param-name>
None.gif<param-value>com.itorgan.tags.extreme.extremetableResourceBundleparam-value>
None.gifcontext-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} u6761u7EAAu5F55u7B26u5408u6761u4EF6, u73B0u5728u662Fu7B2C {1} u81F3 {2} u6761u7EAAu5F55
table.statusbar.noResultsFound=u6CA1u6709u8981u67E5u8BE2u7684u7EAAu5F55u3002
table.toolbar.showAll=u6240 u6709

补充:中文 - > Unicode编码 可通过反编译class文件或用native2ascii命令得到 。

然后在table标签中增加locale属性即可切换

None.gif < ec:table
None.gif ………………
None.gif ………………
None.gif ………………
None.gif locale = " en_US "
None.gif >
None.gif
None.gif < ec:table
None.gif ………………
None.gif ………………
None.gif ………………
None.gif locale = " zh_CN "
None.gif >
None.gif


[2] 保留table的上一次状态
是指,不管跳转到另一个后再返回,extremeTable会将之前的Filter,Sort参数保存到session中,以至返回看到的页面还是之前的状态.

实现操作方法:
修改extremecomponents.properties文件
table.useSessionFilterSortParam=foo
saveFilterSort="true" 注意:saveFilterSort="true"不能在properties文件中配置,只能在页面中设
 < ec:table
None.gif ……………………
None.gif saveFilterSort = " true "
None.gif / ec:table >
None.gif < a href = " 1.jsp " > 跳到 a>

新建一页面用于跳转的页面 1.jsp
代码为

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

None.gif < div class ="eXtremeTable" >
None.gif < table border ="0" cellpadding ="0" cellspacing ="0" width ="100%" >
None.gif < tr >
None.gif < td class ="title" >< span > 标题--&gtspan>td>
None.gif<td align="right" >
None.gif<table border="0" cellpadding="0" cellspacing="1" class="toolbar" >
None.gif<tr>
None.gif<form. name="pres_toolbar" action="/extremesite/public/demo/presidents.jsp" >
None.gif工具栏,包括上一页,下一页以及导出--&gt
None.giftr>
None.gif<tr>
None.gifform>
None.giftr>
None.giftable>
None.giftd>
None.giftr>
None.giftable>
None.gif
None.gif<table id="pres" border="0" cellspacing="2" cellpadding="0" width="100%" class="tableRegion" >
None.gif<tr>
None.gif<td colspan="6" >
None.gif<table border="0" cellpadding="0" cellspacing="0" width="100%" >
None.gif<tr>
None.gif<td class="statusBar" >43 results found, displaying 1 to 12 td>
None.gif<td class="filterButtons" >td>
None.giftr>
None.giftable>
None.giftd>
None.giftr>
None.gif
None.gif<form. name="pres_filter" action="/extremesite/public/demo/presidents.jsp" >
None.gif<tr class="filter" id="filter" >
None.gif--&gt
None.giftr>
None.gifform>
None.gif<tr>
None.giftableHead--&gt
None.giftr>
None.gif<tbody class="tableBody" >
None.gif<tr>
None.gifcolumn--&gt
None.giftr>
None.giftbody>
None.giftable>
None.gifdiv>
None.gif


extremeTable支持样式快速切换.可自定的样式包括column 的td以及table的一些属性,例如cellpadding等,
另本人发现,在properties中如下设置tableHeader的样式是不行的.不知道是否一个BUG
table.headerClass=itoTableHeader
table.headerSortClass=itoTableHeaderSort

只能继承一个HeaderCell

None.gif public class HeaderCell extends org.extremecomponents.table.cell.HeaderCell
ExpandedBlockStart.gifContractedBlock.gif dot.gif {
InBlock.gifpublic final static String TABLE_HEADER = "itoTableHeader";
InBlock.gifpublic final static String TABLE_HEADER_SORT = "itoTableHeaderSort";
InBlock.gif

新的样式代码:

None.gif < LINK REL = " stylesheet " HREF = " "/style.css"/>" TYPE="text/css">

效果见下:
ec[2].jpg

[4] 实现 table width 自动累加
原来的extremeTable 宽度要自己set。不会自动能过下面的column累加。
本人作了个修改以达到自动累加,省得自己加写上去:
查看htmlView.java 两处地方 
toolbarPlacement
tableStart可见两处地方要修改的


[5] custom cell
在properties文件中我们可观察到:

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

当 column 默认使用org.extremecomponents.table.cell.DisplayCell

ExpandedBlockStart.gif ContractedBlock.gif public class DisplayCell extends BaseCell dot.gif {
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gifpublic String html() dot.gif{
InBlock.gif HtmlBuilder html = new HtmlBuilder();
InBlock.gif
InBlock.gif html.append(startTD());
InBlock.gif
InBlock.gif Object value = column.getValue();
ExpandedSubBlockStart.gifContractedSubBlock.gifif (value != null && StringUtils.isNotEmpty(value.toString())) dot.gif{
InBlock.gif html.append(value);
ExpandedSubBlockStart.gifContractedSubBlock.gif }
else dot.gif{
InBlock.gif html.append(" ");
ExpandedSubBlockEnd.gif }

InBlock.gif
InBlock.gif html.append(endTD());
InBlock.gif
InBlock.gifreturn html.toString();
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif

ec已其它cell
日期格式化: cell = " date " format = " yyyy-MM-dd "
数字格式化: cell="currency" format="###,###,##0.00"


另外,extremeTable支持自定义cell
在这里我以一个简单的例子[以input框的形式出现] 说明如何实现这一方便的扩展

None.gif public class DemoInput extends BaseCell
ExpandedBlockStart.gifContractedBlock.gif dot.gif {
InBlock.gifpublic String html()
ExpandedSubBlockStart.gifContractedSubBlock.gifdot.gif{
InBlock.gif Integer rowNum = rowcount;
InBlock.gif HtmlBuilder html = new HtmlBuilder();
InBlock.gif html.append(startTD());
InBlock.gif Object value = column.getValue();
InBlock.gif HtmlBuilder input = new HtmlBuilder();
InBlock.gif input.input("text");
InBlock.gif input.name(column.getProperty() + "_" + rowNum);
InBlock.gif input.value(value.toString());
InBlock.gif input.close();
InBlock.gif html.append(input.toString());
InBlock.gif html.append(endTD());
InBlock.gifreturn html.toString();
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}


properties文件增加

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

jsp代码

None.gif < ec:column property = " code " title = " 编号 " width = " 100 " cell = " demoInput " styleClass = " GridTd " />

效果显示为
当然这只是一个简单的demo以说明如何自定义cell
如上面你可以简单的实现同样功能

None.gif < ec:column property ="code" title ="编号" width ="100" styleClass ="GridTd" >
None.gif < input type ="text" value ="${goodss.code}" name ="code_${ROWCOUNT}" >
None.gif ec:column>



[6]Extended Attributes
新版本支持Extended Attributes,方便了用户扩展,记得0.9版本时还要我修改N个地方,现在为table,column增加attribute方便多了.
为table增加一个height的属性

None.gif public class TableTag extends org.extremecomponents.table.tag.TableTag
ExpandedBlockStart.gifContractedBlock.gif dot.gif {
InBlock.gif//div 的高度
InBlock.gif private String height;
InBlock.gif
LI>%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<p%20style=

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

上一篇: 面试题
user_pic_default.png
请登录后发表评论 登录
全部评论
<%=items[i].createtime%>

<%=items[i].content%>

<%if(items[i].items.items.length) { %>
<%for(var j=0;j
<%=items[i].items.items[j].createtime%> 回复

<%=items[i].items.items[j].username%>   回复   <%=items[i].items.items[j].tousername%><%=items[i].items.items[j].content%>

<%}%> <%if(items[i].items.total > 5) { %>
还有<%=items[i].items.total-5%>条评论 ) data-count=1 data-flag=true>点击查看
<%}%>
<%}%> <%}%>

转载于:http://blog.itpub.net/122100/viewspace-657/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值