本站首页    管理页面    写新日志    退出


«July 2025»
12345
6789101112
13141516171819
20212223242526
2728293031


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7571030
建立时间:2006年5月29日




[eXtremeComponents]eXtremeComponents FAQ(中文)
软件技术,  电脑与网络

lhwork 发表于 2006/6/28 10:45:32

eXtremeComponents FAQ eXtremeComponents FAQ(中文版) Jeff Johnston Lucky 冷月宫主 版本0.1.0 本文档允许在遵守以下两条原则的条件下被使用和传播: 1)不能凭借本文档索取任何费用 2)以任何方式(印刷物或电子版)使用和传播时本文档时,必须包含本版权申明 (更新中...) Table of Contents eXtremeComponents FAQ(中文) 1. 如何使用导出功能2. 传入中文参数乱码3. 导出时中文文件名乱码4. 导出时文件内容乱码5. 变量命名问题6. 格式化输出表单中的数据7. 加入链接8. 行高亮显示 eXtremeComponents FAQ(中文) 1. 如何使用导出功能 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> 2. 传入中文参数乱码 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> 3. 导出时中文文件名乱码 Q:关于导出时中文文件名为乱码的问题 A: 这是个bug,建议使用英文文件名,主要原因还是编码问题。我们现在正在想办法解决。 4. 导出时文件内容乱码 Q:导出时文件内容乱码 A:首先请确认使用的是extremecomponents-1.0.1-M5-A4版以后的版本 Excle: 导出为Excle的中文问题已经修正,默认的情况下支持导出中文,用户不需要任何改动 PDF : 由于extremecomponents使用了FOP来生成PDF文件,FOP在导出中文内容时会产生乱码。具体的解决方案 大家可以参考最新eXtremeComponents包:支持 PDF中文导出 5. 变量命名问题 Q:当变量名为"action",在IE下执行产生javascript错误 A: 内部使用了一些关键字,就目前我所知的为"action"、"submit"。建议大家命名时尽量避免,如果大家必须使用,则可以使用table标签的autoIncludeParameters参数设置为"false": autoIncludeParameters="false" 6. 格式化输出表单中的数据 Q:怎么样格式化输出表单中的数据 A: 你可以设置列的cell: 日期格式化: cell = " date " format = " yyyy-MM-dd " 数字格式化: cell="currency" format="###,###,##0.00" 详细信息请参考指南 7. 加入链接 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> 8. 行高亮显示 Q: 我想使用行的高亮显示如何设置 A: 你只需要设置行标签的highlightRow属性: highlightRow="true"。eXtremeComponents提供了很多接口允许用户按照自己的习惯来进行定制,包括:CSS、CELL、View。相关信息请参考指南。


阅读全文(4615) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.061 second(s), page refreshed 144753734 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号