extremecomponents相关大全
?
安裝要求
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
?
格式化輸出表單中的數據
Q:怎么樣格式化輸出表單中的數據
A: 你可以設置列的cell:
?
在web.xml中添加編碼過濾器配置:
?<filter>???
?<filter-name>Set Character Encoding</filter-name>
??? <filter-class>filters.SetCharacterEncodingFilter</filter-class>???
?<init-param>????
? <param-name>encoding</param-name>?????
<param-value>gb2312</param-value>?
?? </init-param>?
</filter>
? <filter-mapping>??
? <filter-name>Set Character Encoding</filter-name>
??? <url-pattern>/*</url-pattern>?
</filter-mapping>
?
<!--配置導出功能的過濾器-->
<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>?
在extComments中加入鏈接
Q:怎么樣加入鏈接
A: 你可以參考下例:
<ec:tablevar="pres"
items="presidents"
action="${pageContext.request.contextPath}/compact.run"
imagePath="${pageContext.request.contextPath}/images/table/compact/*.gif"
view="compact"
title="Compact Toolbar View"
showTooltips="false"
>
<ec:exportPdf
fileName="output.pdf"
tooltip="Export PDF"
headerColor="black"
headerBackgroundColor="#b6c2da"
headerTitle="Presidents"
text="PDF"
/>
<ec:exportXls
fileName="output.xls"
tooltip="Export Excel"
text="XLS"
/>
<ec:row>
<ec:column property="fullName" title="Name">
<a href="http://www.whitehouse.gov/history/presidents/">${pres.fullName}</a>
</ec:column>
<ec:column property="nickName"/>
<ec:column property="term"/>
<ec:column property="born" cell="date"/>
<ec:column property="died" cell="date"/>
<ec:column property="career"/>
</ec:row>
</ec:table> Limit數據端分頁
package com.sinovs.saler.webapp.action;
?
import java.util.List;
?
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
?
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DispatchAction;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.extremecomponents.table.context.Context;
import org.extremecomponents.table.context.HttpServletRequestContext;
import org.extremecomponents.table.core.Preferences;
import org.extremecomponents.table.core.PreferencesConstants;
import org.extremecomponents.table.core.TableConstants;
import org.extremecomponents.table.core.TableModelUtils;
import org.extremecomponents.table.core.TableProperties;
import org.extremecomponents.table.limit.Limit;
import org.extremecomponents.table.limit.LimitFactory;
import org.extremecomponents.table.limit.TableLimit;
import org.extremecomponents.table.limit.TableLimitFactory;
?
import com.sinovs.saler.model.Saler;
import com.sinovs.saler.service.SalerManager;
?
?
public final class SalerAction extends DispatchAction {
??
??? public ActionForward search(ActionMapping mapping, ActionForm form,
?????????? HttpServletRequest request, HttpServletResponse response)
?????????? throws Exception {
????? //從spring中得到的bean
?
?????? SalerManager mgr = (SalerManager) getBean("salerManager");
?????? /**
?????? ?* controller首先需要創建一個Limit
?????? ?*/
?????? String tableId = "ec";
?????? Context context = new HttpServletRequestContext(request);
?????? LimitFactory limitFactory = new TableLimitFactory(context, tableId);
?????? Limit limit = new TableLimit(limitFactory);
?????? /**
?????? ?* 得到系統默認的頁面顯示大小
?????? ?*/
?????? Preferences preferences = new TableProperties();
?????? preferences.init(null, TableModelUtils.getPreferencesLocation(context));
?
?????? String crdStr = tableId + "_" + TableConstants.CURRENT_ROWS_DISPLAYED;
?????? /**
?????? ?* 注意:此處取值時,如果后臺配置文件里有配置,就從里面取,反之取15
?????? ?*/
?????? int defaultRowsDisplayed = Integer.parseInt(preferences
????????????? .getPreference(PreferencesConstants.TABLE_ROWS_DISPLAYED));
?????? if (request.getParameter(crdStr) != null) {
?????????? defaultRowsDisplayed = Integer.parseInt(request
????????????????? .getParameter(crdStr));
?????? }
?
?????? /**
?????? ?* limit需要得到所有的行來得到行的信息
?????? ?*/
?
?
?????? int totalRows = mgr.getTotalSalers(limit);
?
?????? limit.setRowAttributes(totalRows, defaultRowsDisplayed);
?????? /**
?????? ?* 需要從services得到Collection數據
?????? ?*/
?????? List list = mgr.getSalers(limit);
?
?????? /**
?????? ?* 將Collections和totalRow這些信息傳送回JSP以便eXtremeTable知道如何顯示這些信息
?????? ?*/
?????? request.setAttribute("list", list);
?????? request.setAttribute("totalRows", new Integer(totalRows));
?
?????? return mapping.findForward("list");
??? }
?
}
?SalerManagerImpl
/**
??? ?* controller需要到第一條信息就是總行數。
??? ?*/
??? private final static String salersQuery = "FROM Saler ";
?
??? private final static String totalSalersQuery = "SELECT count(*) FROM Saler ";
?
??? public int getTotalSalers(Limit limit) {
?????? String totalQuery = totalSalersQuery;
?????? String modTotalQuery = filterQuery(limit.getFilterSet(), totalQuery);
?????? int totalRows = dao.getTotalSalers(modTotalQuery);
?????? return totalRows;
??? }
?
??? public List getSalers(Limit limit) {
?????? String query = salersQuery;
?????? String modSalersQuery = filterQuery(limit.getFilterSet(), query);
?????? modSalersQuery = sortQuery(limit.getSort(), modSalersQuery);
?????? return dao.getSalers(modSalersQuery, limit);
?
??? }
?
??? private String filterQuery(FilterSet filterSet, String query) {
?????? if (!filterSet.isFiltered() || filterSet.isCleared()) {
?????????? return query;
?????? }
?
?????? Filter filters[] = filterSet.getFilters();
?????? for (int i = 0; i < filters.length; i++) {
?????????? Filter filter = filters[i];
?????????? String property = filter.getProperty();
?????????? String value = filter.getValue();
?????????? query = filterQuery(query, property, value);
?????? }
?
?????? return query;
??? }
?
??? public String filterQuery(String query, String property, String value) {
?????? StringBuffer result = new StringBuffer(query);
?
?????? if (query.indexOf("WHERE") == -1) {
?????????? result.append(" WHERE 1 = 1 "); // stub WHERE clause so can just
?????????? // append AND clause
?????? }
?
?????? result.append(" AND " + property + " like '%" + value + "%'");
?
?????? return result.toString();
??? }
?
??? private String sortQuery(Sort sort, String query) {
?????? if (!sort.isSorted()) {
?????????? return query;
?????? }
?
?????? String property = sort.getProperty();
?????? String sortOrder = sort.getSortOrder();
?
?????? return sortQuery(query, property, sortOrder);
??? }
?
??? public String sortQuery(String query, String property, String sortOrder) {
?????? StringBuffer result = new StringBuffer(query + " ORDER BY ");
?
?????? result.append(property + " " + sortOrder);
?????? return result.toString();
??? }
?
SalerDaoHibernate
/**
??? ?* 得到數據總行數
??? ?*/
??? public int getTotalSalers(String query) {
?????? int totalRows = 0;
?????? List list = getHibernateTemplate().find(query);
?????? if (list.size() > 0) {
?????????? totalRows = ((Integer) list.get(0)).intValue();
?????? }
?????? return totalRows;
??? }
?
??? /**
??? ?* 根據HQL語句的到紀錄列表
??? ?*/
??? public List getSalers(String query, Limit limit) {
?????? Session session = this.getSession();
?????? Query q = session.createQuery(query);
?????? q.setFirstResult((limit.getPage() - 1)
????????????? * limit.getCurrentRowsDisplayed());
?????? q.setMaxResults(limit.getCurrentRowsDisplayed());
?????? return q.list();
??? }
頁面??
<ec:table
?????? items="salerList"
?????? var="saler"
?????? action="${pageContext.request.contextPath}/saler.do?method=search"
?????? imagePath="${pageContext.request.contextPath}/images/table/*.gif"
?????? title="saler.list.title"
?????? width="80%"
?????? retrieveRowsCallback="org.extremecomponents.table.callback.LimitCallback" filterRowsCallback="org.extremecomponents.table.callback.LimitCallback" sortRowsCallback="org.extremecomponents.table.callback.LimitCallback"
?????? rowsDisplayed="16"
?????? >
?????? <ec:exportXls fileName="presidents.xls" tooltip="Export Excel"/>
?????? <ec:row? highlightRow="true">
?????????? <ec:column property="rowcount" cell="rowCount" sortable="false" filterable="false" title="ID" width="60"/>
?????????? <ec:column property="salerName" title="saler.salername"/>
?????????? <ec:column property="salerPhone" title="saler.salerphone"/>
?????????? <ec:column property="id" title="saler.button.mod" filterable="false" viewsAllowed="html" sortable="false">
?????????? <a href="${pageContext.request.contextPath}/saler.do?method=edit&id=${saler.id}"><bean:message key="saler.button.mod"/></a>
?????????? </ec:column>
?????????? <ec:column property="id" title="saler.button.delete" filterable="false" sortable="false" viewsAllowed="html">
?????????? <a href="${pageContext.request.contextPath}/saler.do?method=delete&id=${saler.id}"><bean:message key="saler.button.delete"/></a>
?????????? </ec:column>
?????? </ec:row>
??? </ec:table>?
創建Limit
首先你需要通過LimitFactory得到一個Limit實例:
Context context = new HttpServletRequestContext(request);LimitFactory limitFactory = new TableLimitFactory(context, tableId);
Limit limit = new TableLimit(limitFactory);
總結
以上是生活随笔為你收集整理的extremecomponents相关大全的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 32款图片处理软件介绍
- 下一篇: 使用weblogic部署若依项目(图文教