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

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

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

    風人園

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

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

    一、eXtremeTable導出亂碼的問題

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

    A4.zip(注:我下時還是M4今天變成M5了,開發(fā)人員真勤快呀)),這個問題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。如果沒有則下載最新的版本。

    二、傳遞中文參數(shù)出現(xiàn)亂碼的問題

    如你的查詢參數(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ù),那怕是經過了action的mapping.findForward("forward"),在我的試用

    過程中到頁面上會出現(xiàn)傳遞過去的參數(shù),但出現(xiàn)了亂碼問題,因此向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,但目前在我的測試環(huán)境中無法解決中文問題。

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

    解決方法同上

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

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

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

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

    應的數(shù)據(jù)處理-->返回結果頁面。(經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.生成字體規(guī)格文件

    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
    如果你的系統(tǒng)裝在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環(huán)境里的路徑就好了,我

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

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

    修改里面出現(xiàn)的<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的實例是沒有使用的,僅使用它的構造函數(shù)加載了配置文件,通過以上步驟導出的PDF文件就可以正常的看見中文,其它的東方字體

    也同樣可以正常顯示.

    ?

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

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

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

    ?

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

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


    九、怎么樣格式化輸出表單中的數(shù)據(jù)?

    日期格式化: cell = " date " format = " yyyy-MM-dd "
    數(shù)字格式化: 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下載。開發(fā)環(huán)境JB+Struts+tomcat5.5.
    注意:下載時必須用工具下載,不能用IE直接打開下載。


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

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


    相關貼子鏈接:

    eXtremeComponent在中文環(huán)境下的使用

    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 風人園 閱讀(2851) 評論(0)  編輯  收藏 所屬分類: Java

    主站蜘蛛池模板: 久久亚洲精品成人无码网站| 免费在线观看视频a| 亚洲一区二区三区香蕉| 国产综合成人亚洲区| 思思99re66在线精品免费观看| 91亚洲精品视频| 中文字幕成人免费视频| 亚洲精品国产日韩无码AV永久免费网 | 亚洲乱妇老熟女爽到高潮的片| 亚洲免费闲人蜜桃| 亚洲国产成人九九综合| 国产精品免费观看久久| 亚洲中文字幕无码久久精品1 | 黄色片网站在线免费观看| 中文字幕免费不卡二区| 亚洲精品综合一二三区在线| 黄人成a动漫片免费网站| 亚洲人午夜射精精品日韩| 中国一级毛片视频免费看| 亚洲Aⅴ无码专区在线观看q| 亚洲免费视频播放| 欧美激情综合亚洲一二区| 亚洲欧洲中文日韩av乱码| 18禁超污无遮挡无码免费网站 | 亚洲精品乱码久久久久久久久久久久 | 成人在线免费视频| 国产亚洲人成无码网在线观看| 精品国产一区二区三区免费| 亚洲精品国产专区91在线| 有色视频在线观看免费高清在线直播 | 香蕉大伊亚洲人在线观看| 免费一区二区视频| 美女视频黄a视频全免费网站色窝| 亚洲精品国产福利片| 免费观看一级毛片| 91亚洲性爱在线视频| 午夜电影免费观看| a级毛片免费高清毛片视频| 亚洲人成电影青青在线播放| 免费一级毛片不卡在线播放| 久久午夜伦鲁片免费无码|