幸せのちから

          平凡的世界
          看似平常實崎嶇
          成如容易卻艱辛

          eXtremeComponents FAQ(中文)

          eXtremeComponents FAQ

          eXtremeComponents FAQ(中文版)

          Jeff Johnston

          Lucky

          冷月宮主

          版本0.1.0

          本文檔允許在遵守以下兩條原則的條件下被使用和傳播: 1)不能憑借本文檔索取任何費用 2)以任何方式(印刷物或電子版)使用和傳播時本文檔時,必須包含本版權申明

          (更新中...)


          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.?傳入中文參數(shù)亂碼

          Q: 傳入中文參數(shù)亂碼,如下頁面:

          		<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的結果頁面會自動取得頁面上的表單參數(shù),那怕是經(jīng)過了action的mapping.findForward("forward"),在我的試用過程中到頁面上會出現(xiàn)傳遞過去的參數(shù),但出現(xiàn)了亂碼問題,使用查詢(filter)功能是的中文參數(shù)問題類似。

          A:

          1. 確認服務器的參數(shù)是否設置了正確的編碼,如果使用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" />
          2. 添加編碼過濾器到你的應用工程:

            /*
            * 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);

            }


            }
          3. 在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,建議使用英文文件名,主要原因還是編碼問題。我們現(xiàn)在正在想辦法解決。

          4.?導出時文件內容亂碼

          Q:導出時文件內容亂碼

          A:首先請確認使用的是extremecomponents-1.0.1-M5-A4版以后的版本

          1. Excle: 導出為Excle的中文問題已經(jīng)修正,默認的情況下支持導出中文,用戶不需要任何改動
          2. PDF : 由于extremecomponents使用了FOP來生成PDF文件,F(xiàn)OP在導出中文內容時會產(chǎn)生亂碼。具體的解決方案 大家可以參考最新eXtremeComponents包:支持 PDF中文導出

          5.?變量命名問題

          Q:當變量名為"action",在IE下執(zhí)行產(chǎn)生javascript錯誤

          A: 內部使用了一些關鍵字,就目前我所知的為"action"、"submit"。建議大家命名時盡量避免,如果大家必須使用,則可以使用table標簽的autoIncludeParameters參數(shù)設置為"false":

          autoIncludeParameters="false"

          6.?格式化輸出表單中的數(shù)據(jù)

          Q:怎么樣格式化輸出表單中的數(shù)據(jù)

          A: 你可以設置列的cell:

          1. 日期格式化: cell = " date " format = " yyyy-MM-dd "
          2. 數(shù)字格式化: 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 >${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。相關信息請參考指南。

          posted on 2006-03-31 15:07 Lucky 閱讀(11154) 評論(14)  編輯  收藏 所屬分類: extremeComponents

          評論

          # re: eXtremeComponents FAQ(中文) 2006-03-31 18:34 keith

          冷月宮主 是誰?好熟悉啊!  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-03-31 18:55 Lucky

          我旁邊的技術鏈接有鏈接,你可以去他網(wǎng)站看看,資料挺多的。  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-04-01 12:51 差沙

          關于導出時中文文件名為亂碼的問題

          還是因為那個編碼過濾器的問題。  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-04-01 13:33 Lucky

          @差沙
          你說的很對,就是因為加的編碼過濾器導致亂碼。  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-04-03 12:06 冷月宮主

          我又經(jīng)過測試,確實是加過濾器引起的,但還沒有找到解決的辦法。  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-04-03 12:16 xplucky

          是啊,我現(xiàn)在正在想該怎么處理?我最近比較忙,沒有太多時間花在這上面。大家多想想、討論討論。  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-04-07 17:19 seno

          導出時中文文件名為亂碼的問題的解決見http://www.springside.org.cn/docs/reference/ExtremeTable.htm  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2006-04-07 19:38 Lucky

          @seno
          你提到的SpringSide的這個文件名亂碼方案,的確很強,我以前也實現(xiàn)了一個類似的。用這個同時會有一個問題,就是假如原來的文件名就是UTF-8? 我現(xiàn)在就碰到這樣的情況。現(xiàn)在問題的關鍵: 我如何得到一個字符串使用的編碼(gb2312、ISO、UTF-8),不知道哪位知道?  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2007-04-06 15:29 曾志香

          你好,在freemarker下如何引用eXtremeComponents的標簽庫?也就像在jsp下可以引用,為何在freemarker不可以嗎?如有好的例子,能否給大家展示一下!~謝謝 !
          email:axiang_2898@126.com  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2007-06-01 15:40 sweetleaf

          我在appfuse中,試著使用eXtremeComponents的標簽庫,test.jsp頁面能正常顯示,但是加入<ec:exportXls
          fileName="dd.xls"
          tooltip="Export Excel"
          text="XLS"
          />后,點擊導出xls的圖標,頁面跳轉到一個空頁面,名稱也為test.jsp,無任何內容顯示,請問,這是怎么回事?
            回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2007-06-29 18:47 peterwillcn

          加入的過濾器 好像和導出文件的過濾器 沖突...  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2007-08-29 16:33 乖乖兔

          請問eXtremeComponents的過濾功能,即查詢?yōu)槭裁床恢С种形哪兀坎樵儠r文本框是亂碼.有什么辦法可以解決? 感覺東西好了,但是教程方面說的還是不詳細..不知道怎么樣擴展及修改filter...另外Ecide這個東西,我也下載過,雖然彌補了缺憾,但是畫面我不喜歡,很花俏..沒有eXtremeComponents好  回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2007-08-30 14:20 鄧名剛

          請問一下,我使用extremeTable,并且在action中使用limit來分頁,但是有些jsp頁面,我沒有用到<ec:table>的標簽, 而是自己用循環(huán)生成表格,所以我想自己寫分頁標簽以便使用在action中已經(jīng)提供好的limit功能.不知這個分頁標簽該如何做?
          還望各位賜教!
          謝謝!
            回復  更多評論   

          # re: eXtremeComponents FAQ(中文) 2007-11-27 00:12 專注java開源

          http://www.agilesource.org
          這里有很多例子  回復  更多評論   

          <2006年3月>
          2627281234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          導航

          隨筆分類(125)

          文章分類(5)

          日本語

          搜索

          積分與排名

          最新隨筆

          最新評論

          主站蜘蛛池模板: 曲阜市| 济南市| 云龙县| 奇台县| 油尖旺区| 集安市| 菏泽市| 马鞍山市| 广水市| 丹寨县| 商河县| 壶关县| 禄劝| 石阡县| 文成县| 甘孜| 龙州县| 靖江市| 茶陵县| 宝清县| 青海省| 安溪县| 石屏县| 当涂县| 惠来县| 灵武市| 星座| 巴彦淖尔市| 丰台区| 马公市| 道真| 吴桥县| 沁水县| 石家庄市| 宝山区| 尼勒克县| 松原市| 贵德县| 平武县| 胶南市| 内丘县|