<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    風人園

    弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
    隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
    數據加載中……

    eXtremeTable在開發過程中遇到的問題及解決辦法

    一、eXtremeTable導出亂碼的問題

    請下載最新的eXtremeComponents-1.0.1-M4(http://extremecomponents.org/extremesite/public/download/extremecomponents-1.0.1-M5-

    A4.zip(注:我下時還是M4今天變成M5了,開發人員真勤快呀)),這個問題lucky(http://m.tkk7.com/lucky/)解決,在包中加了過濾器

    ,只需要在web.xml文件中加入以下內容即可:
    ? <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>
    注:首先確認一點你的包中是否有org.extremecomponents.table.filter.ExportFilter。如果沒有則下載最新的版本。

    二、傳遞中文參數出現亂碼的問題

    如你的查詢參數頁面,如下表示:

    <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"),在我的試用

    過程中到頁面上會出現傳遞過去的參數,但出現了亂碼問題,因此向lucky請教,給出了如下解決方法,同樣使用的過濾器,在這里要要提醒大

    家一點,如果你在程序中使用了大量的new String(tmpArr[i].getBytes("ISO-8859-1"), "GBK"),可能會影響你的程序,你可以做這測試再用

    ,或是修改你的代碼。

    首先編寫字符過濾類(SetCharacterEncodingFilter.java):

    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;

    public class SetCharacterEncodingFilter implements Filter {
    ??? public void destroy() {

    ??????? this.encoding = null;
    ??????? this.filterConfig = null;

    ??? }

    ??? public void doFilter(ServletRequest request, ServletResponse response,
    ???????????????????????? FilterChain chain)
    ??? throws IOException, ServletException {
    ??????? if (ignore || (request.getCharacterEncoding() == null)) {
    ??????????? String encoding = selectEncoding(request);
    ??????????? if (encoding != null)
    ??????????????? request.setCharacterEncoding(encoding);
    ??????? }
    ??????? chain.doFilter(request, response);
    ??? }

    ??? 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 String selectEncoding(ServletRequest request) {
    ??????? return (this.encoding);
    ??? }
    }

    然后修改web.xml加入:
    ? <filter>
    ??? <filter-name>Set Character Encoding</filter-name>
    ??? <filter-class>com.eXtremeTable.filters.SetCharacterEncodingFilter</filter-class>
    ??? <init-param>
    ????? <param-name>encoding</param-name>
    ????? <param-value>GBK</param-value>
    ??? </init-param>
    ? </filter>
    ? <filter-mapping>
    ??? <filter-name>Set Character Encoding</filter-name>
    ??? <url-pattern>/*</url-pattern>
    ? </filter-mapping>

    這里注意一點,我這里用了GBK,如果你要用GB2312也可以,如果支持國際化,你可以改為UTF-8,但目前在我的測試環境中無法解決中文問題。

    四、在過濾(即查找)時出現亂碼(eXtremeTable使用過濾時的中文問題)

    解決方法同上

    五、關于導出時中文文件名為亂碼的問題(在tomcat5.5下出現這種亂碼狀況,在中文weblogic9.1下正常)

    待解決。(注:如果不加上面的過濾器則不會出現亂碼)

    六、關于參數在eXtremeTable中傳遞的一點理解

    查詢參數頁面-->action-->結果頁面(自動取得參數不用人工干預)-->當過濾(查找)導出或排序時再次進入action-->action取得參數-->做相

    應的數據處理-->返回結果頁面。(經lucky(此開源組織成員)確認)

    七、關于導出PDF的中文支持問題(Lucky)

    ??? 1)注冊字體: 選擇自己想要使用的字體(例如: 宋體),使用fop的TTFReader轉換。
    ?????? 大家可以參照FOP:font 進行,也可以自己在網上找一下相關的參照;
    ?? 2) 編輯字體的配置文件: userconfig.xml
    ?????? 增加要使用字體的聲明
    ?????? 并將它放在工程的目錄中比如:org.extremesite.resource.userconfig.xml
    ? 3) 在對應的extremeComponents的配置文件(extremesite的配置文件:extremecomponents.properties)中增加

    exportPdf.userconfigLocation和 exportPdf.font:
    exportPdf.userconfigLocation=/org/extremesite/resource/userconfig.xml
    exportPdf.font=arialuni
    ?? 4)在相應的JSP頁面,增加PDF的標簽

    網友zjcfan的解決辦法(這種方法會修改到源程序,大家看看有沒有更好的解決辦法):
    如果的eXtremeTable導出的PDF中的中文都是#符號的話,那你要需要進行以下的一些步驟:
    1.生成字體規格文件

    java -cp fop.jar org.apache.fop.fonts.apps.TTFReader c:\windows\fonts\simkai.ttf simkai.xml

    java -cp fop.jar org.apache.fop.fonts.apps.TTFReader -ttcname "SimSun" c:\windows\fonts\simsun.ttc simsun.xml
    如果你的系統裝在WINNT下,則將上面的windows換掉.

    2.配置userconfig.xml

    這個文件在fop.jar包的conf文件夾里,需要加入以下font

    <font metrics-file="E:/eXtremeTable/font/simsun.xml" kerning="yes" embed-file="c:/windows/fonts/simsun.ttc">
    ?<font-triplet name="xtsimsun" style="normal" weight="normal"/>
    </font>
    <font metrics-file="E:/eXtremeTable/font/simkai.xml" kerning="yes" embed-file="c:/windows/fonts/simkai.ttf">
    ?<font-triplet name="xtsimkai" style="normal" weight="normal"/>
    </font>

    這里用到的simsun.xml和simkai.xml就是第一步生成的(這里必須指定本地路徑E:/eXtremeTable/font/,如果能改為WEB環境里的路徑就好了,我

    試了一下,好像不行,有誰會呀,教我!)

    3.修改org.extremecomponents.table.view.PdfView.

    修改里面出現的<fo:block>標簽的font-family屬性,設為上面的xtsimkai.

    4.修改org.extremecomponents.table.filter.ExportFilter.

    在driver.run()前加幾條語句,加載剛才我們配置的那個userconfig.xml文件.

    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    InputStream is = loader.getResourceAsStream("conf/userconfig.xml");
    Options options = new Options(is);

    在這里Options的實例是沒有使用的,僅使用它的構造函數加載了配置文件,通過以上步驟導出的PDF文件就可以正常的看見中文,其它的東方字體

    也同樣可以正常顯示.

    ?

    (注:相關的FOP字體大家可以參考下面IBM developerWorksd兩篇文獻:

    如何在程序中嵌入FOP(http://www-128.ibm.com/developerworks/cn/xml/x-fop/index.html

    在 Web 應用程序中動態生成國際化的 PDF(http://www-128.ibm.com/developerworks/cn/xml/x-ospdf/))

    ?

    八、關于變量使用和表單命名的問題

    在表單或是變量命名時不要使用action做為表單名或是變量名。(暫只知action如果有其它大家可以補上)


    九、怎么樣格式化輸出表單中的數據?

    日期格式化: cell = " date " format = " yyyy-MM-dd "
    數字格式化: cell="currency" format="###,###,##0.00"

    十、怎么樣加入鏈接?

    示例:
    ? <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=">
    ??????????? </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>

    十一、加入<tr class="odd"? onmouseover="this.className='highlight'"? onmouseout="this.className='odd'" >特性

    在<ec:row>中加入highlightRow="true"屬性,可以修改CSS文件自定義。

    使用示例:
    <ec:table items="mytable" action="${pageContext.request.contextPath}/eXtremeDemo.jsp"

    imagePath="${pageContext.request.contextPath}/images/zh_CN/*.gif" cellpadding="1" title="my bread" locale="zh_CN">
    ? <ec:exportXls fileName="中文.xls" tooltip="導出為電子表格文件" text="XLS"/>
    ? <ec:exportCsv fileName="中文.csv" tooltip="導出為CSV文件" text="CSV"/>
    ? <ec:exportPdf fileName="中文.pdf" tooltip="導出為PDF文件" text="PDF"/>
    ? <ec:row>
    ??? <ec:column property="code"/>
    ??? <ec:column property="name"/>
    ??? <ec:column property="status"/>
    ??? <ec:column property="born" cell="date" format="yyyy-MM-dd"/>
    ? </ec:row>
    </ec:table>

    ?

    附:關于eXtremeTable使用,我也是剛剛接觸,非常感謝lucky的熱心幫助。再次表示感謝!


    關于這個示例大家可以去
    http://www.seg-gps.com:8080/bak/eXtremeTableAJAXDemo.rar下載。開發環境JB+Struts+tomcat5.5.
    注意:下載時必須用工具下載,不能用IE直接打開下載。


    http://www.seg-gps.com:8080/bak/eXtremeComponents參考文檔.doc

    CHM版得正式版出后再制作。


    相關貼子鏈接:

    eXtremeComponent在中文環境下的使用

    http://www.hibernate.org.cn/viewtopic.php?t=17938

    演示示例:

    http://www.extremecomponents.org/extremesite/public/demo/examples.jsp

    eXtremeComponents參考文檔(中文)

    http://m.tkk7.com/lucky/articles/33380.html

    學習eXtremeTable的初步好文章

    http://m.tkk7.com/davidxu/archive/2005/08/09/9683.aspx

    posted on 2006-07-06 17:11 風人園 閱讀(2848) 評論(0)  編輯  收藏 所屬分類: Java

    主站蜘蛛池模板: 国产男女爽爽爽免费视频 | 亚洲小说区图片区另类春色| 亚洲乱亚洲乱妇无码| 日本免费网址大全在线观看| 亚洲人成片在线观看| 99久久综合国产精品免费| 精品日韩99亚洲的在线发布| 国产日本一线在线观看免费| 色婷五月综激情亚洲综合| 好男人看视频免费2019中文| 亚洲欧洲国产综合AV无码久久| 日韩一级免费视频| 青青草国产免费国产是公开| 国产精品V亚洲精品V日韩精品| 在线观看免费黄网站| 亚洲国产精品久久久久网站 | 青娱乐免费视频在线观看| 亚洲xxxxxx| 日本免费一区尤物| 九九免费久久这里有精品23| 亚洲熟妇无码AV在线播放| 无码av免费一区二区三区| 亚洲宅男天堂a在线| 波多野结衣久久高清免费| 亚洲精品黄色视频在线观看免费资源 | 亚洲成a人片在线播放| 久久国产精品免费一区| 亚洲综合一区二区国产精品| 岛国av无码免费无禁网站| 大片免费观看92在线视频线视频| 亚洲国产精品久久久天堂| 成人免费福利视频| 黄网站色视频免费看无下截| 国产日韩亚洲大尺度高清| 中文字幕av无码无卡免费| 亚洲高清免费视频| 亚洲中文字幕精品久久| 亚洲中文字幕久久精品无码喷水| 色播精品免费小视频| 十八禁的黄污污免费网站| 久久精品国产亚洲AV高清热|