使用ecside工具,你需要准备的有:
1、ecside.jar
2、 ecside.tld标签
3、ecside.js
4、ecside.css
5、ecside使用table图片
注:以上内容均可在圈子中下载到。
<!-- ecside export filter --> < filter > < filter-name > ecsideExport </ filter-name > < filter-class > org.ecside.filter.ECSideFilter </ filter-class > < init-param > < param-name > useEasyDataAccess </ param-name > < param-value > true </ param-value > </ init-param > < init-param > < param-name > useEncoding </ param-name > < param-value > true </ param-value > </ init-param > < init-param > < param-name > encoding </ param-name > < param-value > UTF-8 </ param-value > </ init-param > </ filter > < filter-mapping > < filter-name > ecsideExport </ filter-name > < url-pattern > /* </ url-pattern > </ filter-mapping >
< taglib > < taglib-uri > /WEB-INF/ecside.tld </ taglib-uri > < taglib-location > /WEB-INF/taglib/ecside.tld </ taglib-location > </ taglib >
########### table ############### table.method=post table.width=95% table.pageSizeList=10,20,50,100,1000,2000,all table.rowsDisplayed=10 table.sortable=true ########### column ############### column.format.date=yyyy/MM/dd column.format.number=0.## column.format.currency=###,###,###
/**/ /* * 用ECSide構建列表 * */ public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String v_type = request.getParameter( " type " ); // 0) 設定過濾條件 Map < String, Object > filterMap = new HashMap < String, Object > (); // filterMap.put("content", "test"); Map < String, Object > sortMap = new HashMap < String, Object > (); sortMap.put( " createTime " , " desc " ); // 按照創建時間倒序排列 // 1) 設定ECSide分頁對象 Limit limit = RequestUtils.getLimit(request); // 取总记录数 int pageNo = RequestUtils.getPageNo(request); int pagesize = RequestUtils.getCurrentRowsDisplayed(request); if (pagesize == 0 ) pagesize = PAGESIZE; // 设置总记录数及每页记录数 int totalRows = RequestUtils.getTotalRowsFromRequest(request); if (totalRows <= 0 ) { totalRows = getEntityManager() .getCount(getEntityClass(), filterMap); } limit.setRowAttributes(totalRows, pagesize); // 根據參數得到結果 List < Bulletin > result = getEntityManager().queryForListByCriter( getEntityClass(), filterMap, sortMap, ((pageNo - 1 ) * pagesize), pagesize); request.setAttribute(getEntityListName(), result); request.setAttribute( " myPageSize " , getPageSize(request)); request.setAttribute( " type " , v_type); return mapping.findForward(LIST); }
/**//*分页查询数据*/ public List queryForListByCriter(Class entityClass, Map filter, Map sortMap, int start, int everypage) { Criteria criteria = getCriteria(entityClass); setFilter(criteria, filter); setSort(criteria, sortMap); criteria.setFirstResult(start); criteria.setMaxResults(everypage); return criteria.list(); } /**//*计算数据条数*/ public int getCount(Class entityClass, Map filter) { Criteria criteria = getCriteria(entityClass); setFilter(criteria, filter); criteria.setProjection(Projections.rowCount()); return ((Integer) criteria.uniqueResult()).intValue(); }
<% @ page contentType = " text/html; charset=UTF-8 " %> <% @ taglib uri = " /WEB-INF/ecside.tld " prefix = " ec " %> <% @ taglib uri = " http://java.sun.com/jsp/jstl/core " prefix = " c " %> <% @ taglib uri = " http://java.sun.com/jsp/jstl/fmt " prefix = " fmt " %> <% @ taglib uri = " http://java.sun.com/jsp/jstl/functions " prefix = " fn " %> < c:set var ="ctx" value ="${pageContext.request.contextPath}" /> < html > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=UTF-8" /> < META HTTP-EQUIV ="pragma" CONTENT ="no-cache" > < META HTTP-EQUIV ="Cache-Control" CONTENT ="no-cache, must-revalidate" > < META HTTP-EQUIV ="expires" CONTENT ="0" > < title > 公告列表 </ title > < link rel ="stylesheet" type ="text/css" href ="${ctx}/module/bizAcceptance/resources/ecside/css/ecside_style.css" /> < script type ="text/javascript" src ="${ctx}/module/bizAcceptance/resources/ecside/js/prototype_mini.js" ></ script > < script type ="text/javascript" src ="${ctx}/module/bizAcceptance/resources/ecside/js/ecside.js" ></ script > < script type ="text/javascript" src ="${ctx}/module/bizAcceptance/resources/ecside/js/ecside_msg_utf8_cn.js" ></ script > </ head > < body > < table width ="100%" border ="0" cellspacing ="0" cellpadding ="0" > <!-- 校验信息 --> < tr > < td class ="left" > <% @ include file = " /module/commons/htmlmessages.jsp " %> </ td > </ tr > < tr > < td height ="30" > < span style ="align:left;font-size:9pt;" > 请选择公告 < input type ="button" name ="Submit3" value ='进 入' onclick ="doView()" > </ span >< br > </ td > </ tr > < tr > < td > < ec:table items ="bulletins" var ="bulletin" retrieveRowsCallback ="limit" filterRowsCallback ="limit" action ="${ctx}/module/bulletin.do?method=list&type=${type}" title ="我的公告列表" useAjax ="false" showPrint ="false" width ="100%" resizeColWidth ="true" filterable ="false" listWidth ="100%" rowsDisplayed ="${myPageSize}" pageSizeList ="${myPageSize},10,15,20,all" xlsFileName ="公告列表.xls" styleClass ="tableRegion" style ="border:2px;table-layout:fixed;" classic ="true" > < ec:row > < ec:column property ="_0" title ="選擇" width ="6%" > < input type ="radio" id ="radio_${GLOBALROWCOUNT}" name ="checkedRadio" value ="${bulletin.id}" > </ ec:column > < ec:column property ="_1" title ="序號" width ="6%" > ${GLOBALROWCOUNT} </ ec:column > < ec:column property ="name" title ="公告名称" > < a href ="JavaScript:doStarting('${affair.id}')" title ="點擊查看" >< c:out value ="${bulletin.name}" /></ a > </ ec:column > < ec:column property ="desn" title ="描述" ellipsis ="true" /> < ec:column property ="createBy" title ="創建人" width ="10%" /> < ec:column property ="createTime" title ="創建時間" width ="20%" > < fmt:formatDate value ="${bulletin.createTime}" pattern ="yyyy-MM-dd HH:mm:ss" /> </ ec:column > < ec:column property ="_2" title ="可執行操作" > < a href ="${ctx}/module/bulletin.do?method=edit&ID=${bulletin.id}" >< img src ="${ctx}/images/affairmgt/update.gif" border ="0" title ="編輯" > 編輯 </ a > < a href ="${ctx}/module/bulletin.do?method=delete&ID=${bulletin.id}" >< img src ="${ctx}/images/affairmgt/delete.gif" border ="0" title ="移除" > 移除 </ a > </ ec:column > </ ec:row > </ ec:table > </ td > </ tr > </ table > < script language ="javascript" > var _confirm = " false " ; var confirmMsg = " 查看此公告? " ; var urlPrefix = " ${ctx}/module/bulletin.do?method=view&ID= " ; function doView(itemId) { if (itemId != null ) { if (_confirm == ' false ' || confirm(confirmMsg)) { ShowWaiting('正在加载数据,请稍候'); window.location = urlPrefix + itemId; } } else { var radio = document.getElementsByName('checkedRadio'); for (i = 0 ; i < radio.length; i ++ ) { if (radio[i].checked) { if (_confirm == ' false ' || confirm(confirmMsg)) { itemId = radio[i].value; ShowWaiting('正在加载数据,请稍候'); window.location = urlPrefix + itemId; } return ; } } alert('请选则一個公告!'); } } </ script > </ body > </ html >
其中,<ec:column property="desn" title="描述" ellipsis="true" />,ellipsis属性实现单元格内数据过长的时候,自动截短并加"..."的功能,但是ie only!因为ff不支持 text-overflow: ellipsis; 使用ellipsis="true"的同时,还要为ec:table加上 style="table-layout:fixed;" (如果您已经使用了调整列宽功能 则不用添加)。