隨筆-40  評(píng)論-66  文章-0  trackbacks-0

          eXtremeComponents FAQ

          eXtremeComponents FAQ(中文版)

          Jeff Johnston

          Lucky

          冷月宮主

          版本0.1.0

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

          (更新中...)


          eXtremeComponents FAQ(中文)


          1.?如何使用導(dǎo)出功能

          Q: 如何使用導(dǎo)出功能

          A: 為了使用導(dǎo)出功能,只需要在web.xml文件中加入eXtremeComponents的導(dǎo)出過(guò)濾器的配置,內(nèi)容如下:

          <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ù)亂碼,如下頁(yè)面:

          		<form id="form1" name="form1" method="post" action="應(yīng)用eXtremeTable的action或是結(jié)果頁(yè)面名">
          <select name="selecttype" size="6">
          <option value="第一個(gè)">第一個(gè)</option>
          <option value="第二個(gè)">第二個(gè)</option>
          <option value="第三個(gè)">第三個(gè)</option>
          </select>
          <input type="text" name="username" />
          <input type="submit" name="Submit" value="提交" />
          </form>

          當(dāng)你提交時(shí)含有eXtremeTable的結(jié)果頁(yè)面會(huì)自動(dòng)取得頁(yè)面上的表單參數(shù),那怕是經(jīng)過(guò)了action的mapping.findForward("forward"),在我的試用過(guò)程中到頁(yè)面上會(huì)出現(xiàn)傳遞過(guò)去的參數(shù),但出現(xiàn)了亂碼問(wèn)題,使用查詢(filter)功能是的中文參數(shù)問(wèn)題類似。

          A:

          1. 確認(rèn)服務(wù)器的參數(shù)是否設(shè)置了正確的編碼,如果使用Tomcat請(qǐng)確認(rèn)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. 添加編碼過(guò)濾器到你的應(yīng)用工程:

            /*
            * 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中添加編碼過(guò)濾器配置:

             <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.?導(dǎo)出時(shí)中文文件名亂碼

          Q:關(guān)于導(dǎo)出時(shí)中文文件名為亂碼的問(wèn)題

          A: 這是個(gè)bug,建議使用英文文件名,主要原因還是編碼問(wèn)題。我們現(xiàn)在正在想辦法解決。

          4.?導(dǎo)出時(shí)文件內(nèi)容亂碼

          Q:導(dǎo)出時(shí)文件內(nèi)容亂碼

          A:首先請(qǐng)確認(rèn)使用的是extremecomponents-1.0.1-M5-A4版以后的版本

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

          5.?變量命名問(wèn)題

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

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

          autoIncludeParameters="false"

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

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

          A: 你可以設(shè)置列的cell:

          1. 日期格式化: cell = " date " format = " yyyy-MM-dd "
          2. 數(shù)字格式化: cell="currency" format="###,###,##0.00"

          詳細(xì)信息請(qǐng)參考指南

          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: 我想使用行的高亮顯示如何設(shè)置

          A: 你只需要設(shè)置行標(biāo)簽的highlightRow屬性: highlightRow="true"。eXtremeComponents提供了很多接口允許用戶按照自己的習(xí)慣來(lái)進(jìn)行定制,包括:CSS、CELL、View。相關(guān)信息請(qǐng)參考指南。



          by lucky
          posted on 2007-01-26 16:04 Super·shen BLOG 閱讀(281) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 毕节市| 湾仔区| 克东县| 安阳县| 绥棱县| 砀山县| 临高县| 南岸区| 定边县| 白水县| 汉寿县| 得荣县| 洪湖市| 竹溪县| 杭锦旗| 什邡市| 上虞市| 共和县| 修武县| 岐山县| 虹口区| 基隆市| 来安县| 类乌齐县| 光山县| 石河子市| 建始县| 安新县| 永和县| 宿州市| 通城县| 长葛市| 华亭县| 禄劝| 武山县| 汉源县| 武城县| 海阳市| 锡林浩特市| 祁东县| 邳州市|