eXtremeComponents FAQ(中文版)
Jeff Johnston
Lucky
冷月宫主
版本0.1.0
本文档允许在遵守以下两条原则的条件下被使用和传播: 1)不能凭借本文档索取任何费用 2)以任何方式(印刷物或电子版)使用和传播时本文档时,必须包含本版权申明
(更新中...)
Table of Contents
Q: 如何使用导出功能
A: 为了使用导出功能,只需要在web.xml文件中加入eXtremeComponents的导出过滤器的配置,内容如下:
<filter>
<filter-name>eXtremeExport</filter-name>
<filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class>
<init-param>
<param-name>responseHeadersSetBeforeDoFilter</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>eXtremeExport</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Q: 传入中文参数乱码,如下页面:
<form id="form1" name="form1" method="post" action="应用eXtremeTable的action或是结果页面名">
<select name="selecttype" size="6">
<option value="第一个">第一个</option>
<option value="第二个">第二个</option>
<option value="第三个">第三个</option>
</select>
<input type="text" name="username" />
<input type="submit" name="Submit" value="提交" />
</form>
当你提交时含有eXtremeTable的结果页面会自动取得页面上的表单参数,那怕是经过了action的mapping.findForward("forward"),在我的试用过程中到页面上会出现传递过去的参数,但出现了乱码问题,使用查询(filter)功能是的中文参数问题类似。
A:
-
确认服务器的参数是否设置了正确的编码,如果使用Tomcat请确认Server.xml:
<Connector port="80" URIEncoding="UTF-8" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false"
redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" /> -
添加编码过滤器到你的应用工程:
/*
* Copyright 1999-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;
/**
* <p>Example filter that sets the character encoding to be used in parsing the
* incoming request, either unconditionally or only if the client did not
* specify a character encoding. Configuration of this filter is based on
* the following initialization parameters:</p>
* <ul>
* <li><strong>encoding</strong> - The character encoding to be configured
* for this request, either conditionally or unconditionally based on
* the <code>ignore</code> initialization parameter. This parameter
* is required, so there is no default.</li>
* <li><strong>ignore</strong> - If set to "true", any character encoding
* specified by the client is ignored, and the value returned by the
* <code>selectEncoding()</code> method is set. If set to "false,
* <code>selectEncoding()</code> is called <strong>only</strong> if the
* client has not already specified an encoding. By default, this
* parameter is set to "true".</li>
* </ul>
*
* <p>Although this filter can be used unchanged, it is also easy to
* subclass it and make the <code>selectEncoding()</code> method more
* intelligent about what encoding to choose, based on characteristics of
* the incoming request (such as the values of the <code>Accept-Language</code>
* and <code>User-Agent</code> headers, or a value stashed in the current
* user's session.</p>
*
* @author Craig McClanahan
* @version $Revision: 1.3 $ $Date: 2004/02/28 03:35:22 $
*/
public class SetCharacterEncodingFilter implements Filter {
// ----------------------------------------------------- Instance Variables
/**
* The default character encoding to set for requests that pass through
* this filter.
*/
protected String encoding = null;
/**
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
*/
protected FilterConfig filterConfig = null;
/**
* Should a character encoding specified by the client be ignored?
*/
protected boolean ignore = true;
// --------------------------------------------------------- Public Methods
/**
* Take this filter out of service.
*/
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
// Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
}
// Pass control on to the next filter
chain.doFilter(request, response);
}
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;
}
// ------------------------------------------------------ Protected Methods
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding</strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request) {
return (this.encoding);
}
} -
在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>
Q:导出时文件内容乱码
A:首先请确认使用的是extremecomponents-1.0.1-M5-A4版以后的版本
- Excle: 导出为Excle的中文问题已经修正,默认的情况下支持导出中文,用户不需要任何改动
- PDF : 由于extremecomponents使用了FOP来生成PDF文件,FOP在导出中文内容时会产生乱码。具体的解决方案 大家可以参考最新eXtremeComponents包:支持 PDF中文导出
Q:当变量名为"action",在IE下执行产生javascript错误
A: 内部使用了一些关键字,就目前我所知的为"action"、"submit"。建议大家命名时尽量避免,如果大家必须使用,则可以使用table标签的autoIncludeParameters参数设置为"false":
autoIncludeParameters="false"
Q:怎么样格式化输出表单中的数据
A: 你可以设置列的cell:
- 日期格式化: cell = " date " format = " yyyy-MM-dd "
- 数字格式化: cell="currency" format="###,###,##0.00"
详细信息请参考指南
Q:怎么样加入链接
A: 你可以参考下例:
<ec:table
var="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>
0
by lucky
相关推荐
eXtremeComponents控件指南
**eXtremeComponents-1.0.1+中文API 分页工具详解** 在软件开发中,尤其是在处理大量数据时,分页功能是必不可少的。它使得用户可以更有效地浏览和管理信息,避免一次性加载过多内容导致的性能问题。本文将深入探讨...
"extremecomponents" 是一个基于Java的组件库,它为开发者提供了丰富的用户界面(UI)组件,用于构建复杂的Web应用程序。这个库特别注重性能和可定制性,使其成为企业级应用开发的理想选择。在...
"eXtremeComponents组件"是一组用于软件开发的组件,尤其在创建高效、功能丰富的用户界面时,这些组件能够极大地提升开发效率和用户体验。eXtremeComponents通常包括一系列的列表控件和其他UI元素,它们设计精良,...
extremecomponents 包
extremeComponents开发指南,快速掌握extremeComponents开发
**eXtremeComponents介绍** eXtremeComponents(简称EC)是一套强大的Java组件库,主要用于构建企业级的Web应用程序。它以其高效、灵活和高度可定制的特点,在开发社区中受到广泛的关注。EC旨在提高开发人员的工作...
- **eXtremeComponents中文指南1.doc**: 这份文档深入介绍了EC的基本概念和使用方法,是初学者入门的必备资料。 - **eXtremeComponents中文指南2.doc**: 进阶指南,涵盖更多高级特性和实战技巧。 - **...
**eXtremeComponents详尽文档包** eXtremeComponents(简称EC)是一个功能强大的组件库,专门针对Java Swing应用程序设计。这个详尽的文档包是为初学者准备的,旨在帮助他们快速掌握EC组件的使用和开发技巧。通过一...
【eXtremeComponents-1.0.3】是一个软件组件包,它的出现是为了提供一套高效、易用的开发工具,以帮助程序员在构建应用程序时提高生产力和代码质量。这个版本1.0.3是该组件集合的一个稳定版本,用户反馈良好,表明它...
eXtremeComponents1.0.1.jar
《深入理解eXtremeComponents:打造高效JSP表格展示》 在Web开发领域,高效地展示数据是一项至关重要的任务,特别是在使用Java Server Pages (JSP) 的项目中。eXtremeComponents 是一个功能强大的组件库,尤其以其...
【eXtremeComponents 源代码】是一个与Java编程相关的资源,主要包含有源代码和.jar包。这个开源项目提供了丰富的组件集合,为开发者在构建Java应用程序时提供了便利。eXtremeComponents的设计目标是提高开发效率,...
《eXtremeComponents控件分页导出数据Demo详解》 在软件开发过程中,高效的数据展示和管理是至关重要的。eXtremeComponents控件系列以其强大的功能和灵活的定制性,在.NET平台上赢得了广大开发者的一致好评。尤其是...
在"extremeComponents中文文档"中,您将找到关于如何配置和有效利用这些组件的详细指南。 1. **组件概述** extremeComponents 包含了多种组件,如表格、树形视图、面板、对话框、菜单、表单元素等。这些组件都...
"ExtremeComponents"是一个开源项目,其源代码包含了用于构建Web应用程序的组件库。这个库主要设计用于提高开发效率,提供了一系列高效、可定制且功能丰富的Web UI组件。这些组件通常包括表格、表单、菜单、按钮等...
eXtremeComponents组件,导出Excel或pdf文件的jar包
eXtremeComponents 的Tag 之一 eXtremeComponents 的Tag 之一
"eXtremeComponents jar+doc+example" 是一个针对数据展示插件的资源包,主要包含`ECTable`的组件。这个插件是IT领域中用于数据展示的强大工具,以其出色的界面设计和丰富的功能而受到青睐。它不仅提供美观的表格...