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

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

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

    零度空間

    To feel the crazy world

    2009年4月15日

    最近要用到iText來處理PDF來提供User與服務器交互的途徑, 所以從Google和Baidu上翻了翻,學到了一點東西, 想Mark下來以后參考,同時也可以和大家交流一下.

    Project最主要是要解決三個方面的問題:

    1.用什么Software來生成可交互的Form?
    2.用什么Open source tools來Pre-fill Form?
    3.在User填完Data后,又以什么方式Submit 到Server處理?

    對于第一個問題,自然是用Adobe 的Software啦,但是用Acrobat Pro還是用Lifecycle Designer, 卻讓我費了不少勁.為什么咧?因為Acrobat Pro和Lifecycle Designer 處理的Form的格式是不一樣的. Acrobat Pro里面用的是AcroForm,是Acrobat3.0開始用的格式,而Lifecycle Designer里面用的是Xfa Form,是基于XML的, 兩者的不同請參考以下的摘錄:      

    Acroforms and XFA forms are different technologies

    The interactive forms that you create in LiveCycle Designer are different than the interactive forms that you create in Adobe Acrobat. If you create an interactive form in Acrobat, your form is based on Adobe’s Acroform technology. This technology dates back to Acrobat version 3, and Adobe provides the “Acrobat Forms API Reference” to provide the technical details for this technology. I would not recommend using Acroform technology because XFA is the better technology.
     
    If you are moving from Acroforms to XFA forms, you need to know a couple of important facts about these two technologies:

    1.LiveCycle Designer can edit a PDF form created in Acrobat, but Acrobat cannot edit a PDF form created in Designer.

    2.JavaScript works differently in these two technologies. Some of the JavaScript routines that work in Acroforms will not work in XFA forms. Adobe has documented these differences in a 43 page online PDF called, “Converting Acrobat JavaScript for Use in LiveCycle Designer Forms.” Designer is a much more robust tool for using JavaScript in your forms, so I recommend that you learn how to script with the XFA object model. See Chapter 4, “Form Scripting,” for more information.

    PS: you can find more in the below link: More info about XFA


            
















     

     







    Lifecycle designer 是后來才有的東西,自然是比Acrobat Pro更先進也更適合用于交互,但我的項目最終還是選了Acrobat Pro,因為我的第二個問題的答案是iText. iText可以用來Pre-fill XFA格式的Form,但是不知道為什么用iText Create的submit button不能submit XFA form(按了Button后沒有反應),后來上網查到原來iText不支持XFA Form, 所以也只能用Acrobat啦.

    而且用Acrobat Pro創建的Form有兩個我自己覺得不錯的優點(以TextFeild類型為例子):

        1. Acrobat Pro創建的AcroForm是沒有層次結構的,而LifeCycle Desinger創建的Form是有層次的.什么意思咧?舉個例子,同樣是Add一個TextFeild, 把它命名為CustomerName,在AcroForm里面的名字就是CustomerName啦,而在XFA Form里面就成了topmostSubForm[0].Page1[0].CustomerName[0],咋一看,還真是煩.而且你的PDF一改的話,那你的Feild name也相應改了,這樣Program也要改了....
        2. Acrobat Pro創建的AcroForm的TextFeild可以自適應大小,一個TextFeild總是有一定的長度,但要填的Value就不知有多長啦,有可能有個CustomerName真的很長咧,這在XFA Form里面就會有些Value Show不出來,但Acrobat Pro創建的AcroForm的TextFeild就可以根據Value的大小而改變字體的大小來適應TextFeild的長度.

    以上兩點是我自己的認識,也許Lifecycle Designer也可以做到以上的效果,但目前我是不會,因為接觸Lifecycle Designer比較少,如果有大蝦知道的話請多多指教.

    posted @ 2009-04-15 11:32 KenLee 閱讀(707) | 評論 (2)編輯 收藏

    2009年2月6日

    今天碰到了個比較奇怪的問題,居然是因為JSP太大導致文件編譯不了,上網查了一下,把解決方法貼下來,以供以后參考:

    The problem is that there is a limit on the size of a compiled method in a
    Java class file, and that limit is what we're running up against. Recall
    that a JSP page is compiled into a servlet, and into essentially only one
    method in that servlet. Hence, if your page contains many, many tags, that
    method becomes too big, and up comes the exception that you're seeing.

    There are a couple of (partial) solutions.

    1) Break your giant page up into multiple smaller pages and bring them
    together at run time using <jsp:include>. Note that <%@include> won't work,
    because that's a compile-time include, which will get you straight back to
    the original problem.

    2) Look for places to save on tags. For example, the <html:option> tag was
    recently extended to allow the specification of the text to display, so
    that you can replace this:

    <html:option ... ><bean:message key="foo"/></html:option>

    with this:

    <html:option ... key="foo"/>

    More info pls access this link: Solution

    我就是用了第一種方法解決的,之前include JSP的時候用了%@include, 后來用了<jsp:include>就不會用問題了.順便貼一下兩者的區別:


    @include & jsp:include的區別
    引用:http://www.ibm.com/developerworks/cn/java/j-jsp04293/

    本文是 Java Brett McLaughlin 繼第一篇 JSP 最佳實踐文章后的后續文章,在文中,作者向您演示了如何擴展 JSP 技術中用于動態內容的包含功能。了解靜態 include 偽指令和動態 jsp:include 元素之間的差異,搞清楚如何混合搭配這二者以獲取最優性能。
    在新的 JSP 最佳實踐系列的前一篇文章中,您了解了如何使用 JSP include 偽指令將諸如頁眉、頁腳和導航組件之類的靜態內容包含到 Web 頁面中。和服務器端包含一樣,JSP include 偽指令允許某個頁面從另一個頁面提取內容或數據。

    清單 1. JSP include 偽指令

    <%@ page language="java" contentType="text/html" %>
    <html>
    <head>
          <title>newInstance.com</title>
          <meta http-equiv="Content-Type"
            content="text/html; charset=iso-8859-1" />
          <link href="/styles/default.css"
            rel="stylesheet" type="text/css" />
    </head>
    <body>
    <%@ include file="header.jsp" %>
    <%@ include file="navigation.jsp" %>
    <%@ include file="bookshelf.jsp" %>
    <%@ include file="/mt-blogs/index.jsp" %>
    <%@ include file="footer.jsp" %>
    </body>
    </html>



    雖然 include 非常適于將靜態內容并入 Web 頁面,但對于動態內容卻不盡如人意。我們在前一篇文章中在試圖重新裝入高速緩存文件時發現了這一問題。與大多數頁眉文件及頁腳文件不同,動態內容變化頻繁,必須時刻更新。我們將首先扼要地重述一下 include 偽指令的局限性,然后我將向您演示如何用 jsp:include 標記來擴展 JSP 的包含能力。


    高速緩存問題

    JSP include 偽指令的不足之處有一個是:它會導致 Web 瀏覽器高速緩存所有頁面。在處理諸如頁腳、版權聲明或一組靜態鏈接之類的靜態組件時,這是有意義的。這些文件不會改變,因此沒有理由讓 JSP 解釋器不斷地重新輪詢其中的數據。凡是可能的地方,都應該實現高速緩存,因為它改善了應用程序的性能。


    但是,有時侯,進行高速緩存會得不償失。如果提入的內容來自使用動態數據(如 Weblog 或數據庫驅動的 JSP 文件)的程序,甚至如果所包含的內容是經常變化的 HTML(如時間戳記),那么每當裝入 Web 頁面時,都需要顯示這些文件或程序的最新版本。遺憾的是,JSP include 偽指令并不具備這一功能。在測試和開發周期中,在瀏覽器中禁用高速緩存通常能夠解決這一問題。但是,對于實際使用的應用程序而言,性能是任何設計決策過程中的一項重要因素,禁用高速緩存并不是一種可行的長遠之計。更好的解決方案是使用 jsp:include 標記。

    jsp:include 標記

    jsp:include 只不過是一個不同于 include 的偽指令而已。 jsp:include 的優點在于:它 總是會檢查所含文件中的變化。過一會兒我們將研究這一新標記的工作方式。但首先看一下兩種 include 各自的代碼,以便能夠看到二者之間的異同。

    清單 2 顯示了一個簡單頁面,它使用了原始的 JSP include 偽指令。


    清單 2. JSP include 偽指令

    <%@ page language="java" contentType="text/html" %>
    <html>
         <head>
          <title>JSP include element test</title>
         </head>
         <body>
          This content is statically in the main JSP file.<br />
          <%@ include file="included.html" %>
         </body>
    </html>


    清單 3 是同一個頁面,只不過這里轉成使用 jsp:include 標記。


    清單 3. 轉成使用 jsp:include

    <%@ page language="java" contentType="text/html" %>
    <html>
         <head>
          <title>JSP include element test</title>
         </head>
         <body>
          This content is statically in the main JSP file.<br />
          <jsp:include page="included.html" flush="true" />
         </body>
    </html>


    您應該注意這兩種代碼類型之間的兩大區別。首先, jsp:include 元素不使用屬于 include 偽指令的 %@ 語法。實際上, jsp 前綴讓 JSP 編譯器知道:它應該尋找標準 JSP 標記集中的元素。其次,指定要包含的文件的屬性從 file 變成了 page 。


    flush 屬性

    您可能已注意到 jsp:include 代碼示例中的 flush 屬性。顧名思義, flush 指示在讀入包含內容之前是否清空任何現有的緩沖區。JSP 1.1 中需要 flush 屬性,因此,如果代碼中不用它,會得到一個錯誤。但是,在 JSP 1.2 中, flush 屬性缺省為 false。由于清空大多數時候不是一個重要的問題,因此,我的建議是:對于 JSP 1.1,將 flush 設置為 true;而對于 JSP 1.2 及更高版本,將其設置為關閉。


    jsp:include 是如何工作的

    如果您有點愛刨根問底,那么可能十分想知道 jsp:include 標記的行為為什么與 include 偽指令不同。道理其實十分簡單: jsp:include 包含的是所包含 URI 的 響應,而不是 URI 本身。這意味著:對所指出的 URI 進行 解釋,因而包含的是 生成的響應。如果頁面是 HTML,那么將得到一點也沒有變化的 HTML。但是,如果是 Perl 腳本、Java servlet 或者 CGI 程序,那么得到的將是從該程序解釋而得的結果。雖然頁面通常就是 HTML,但實際程序恰好是達到目的的手段。而且,由于每次請求頁面的時候都會進行解釋,因此從來不會象使用 include 偽指令時那樣高速緩存結果。雖然這只是很小的變動,但它卻導致了您所見到的行為中的全部差異。


    一種混合搭配的解決方案

    include 偽指令在某些網站上有其用武之地。例如,如果站點包含一些(如果有變化,也很少)幾乎沒有變化的頁眉、頁腳和導航文件,那么基本的 include 偽指令是這些組件的最佳選項。由于 include 偽指令采用了高速緩存,因此只需放入包含文件一次,其內容就會被高速緩存,其結果會是極大地提高了站點的性能。

    然而,對于現在許多 Web 應用程序或站點而言,地毯式的高速緩存并不能解決問題。雖然頁眉和頁腳可能是靜態的,但是不可能整個站點都是靜態的。例如,從數據庫提取導航鏈接是很常見的,并且許多基于 JSP 技術的站點還從其它站點或應用程序上的動態 JSP 頁面提取內容。如果正在處理動態內容,那么需要采用 jsp:include 來處理該內容。

    當然,最好的解決方案是經常把這兩種方法混合搭配使用,將每種構造用到最恰當的地方。清單 4 是混合搭配包含解決方案的一個示例。

    清單 4. 混合搭配解決方案

    <%@ page language="java" contentType="text/html" %>
    <html>
    <head>
    <title>newInstance.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="/styles/default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <jsp:include page="header.jsp" flush="true">
    <jsp:param name="pageTitle" value="newInstance.com"/>
    <jsp:param name="pageSlogan" value=" " />
    </jsp:include>
    <%@ include file="/navigation.jsp" %>
    <jsp:include page="bookshelf.jsp" flush="true" />
    <jsp:include page="/mt-blogs/index.jsp" flush="true" />
    <%@ include file="/footer.jsp" %>
    </body>
    </html>


    上面的代碼顯示了前一篇文章中的示例索引頁面。導航鏈接和頁腳是靜態內容,一年最多更改一次。對于這些文件,我使用了 include 偽指令。內容窗格包含 Weblog 和“bookshelf”組件,它們是動態生成的。這兩個組件需要一直更新,因此對它們,我使用了 jsp:include 標記。 header.jsp 文件有點奇怪。這個組件是從另一個本質上是靜態的 JSP 頁面提取的。但是,正如您將注意到的那樣,它從包含頁提取頁“標語”,然后將它顯示出來。要處理這一共享信息,我們必須向頁眉文件傳入參數。而要處理那些參數,就必須使用 jsp:include 元素。

     
    后記:網上還有一種Solution:

    try giving this in the deployment descriptor.

    <jsp-param>
    <param-name>noTryBlocks</param-name>
    <param-value>true</param-value>
    </jsp-param>

    本人沒有試過, 不知好不好用....

    posted @ 2009-02-06 18:33 KenLee 閱讀(1239) | 評論 (1)編輯 收藏
    僅列出標題  

    導航

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    統計

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    Tech

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久国产乱子伦免费精品| 亚洲av永久无码制服河南实里| 精品视频一区二区三区免费| 亚洲最大中文字幕无码网站| 亚洲AV无码一区二区三区DV| 免费看国产一级特黄aa大片| 韩国免费一级成人毛片| 久久精品免费观看| 亚洲阿v天堂在线2017免费| 亚洲码欧美码一区二区三区| 亚洲精品亚洲人成在线观看麻豆| 内射无码专区久久亚洲| 思思99re66在线精品免费观看| 污视频在线观看免费| 99免费在线视频| 春意影院午夜爽爽爽免费| 精品国产亚洲一区二区三区在线观看 | 亚洲AV无码一区二区大桥未久 | 四虎精品成人免费视频| 亚洲色大成网站www尤物| 亚洲伊人久久大香线焦| 337p欧洲亚洲大胆艺术| 亚洲精品免费在线观看| 久久精品国产亚洲av成人| 亚洲精品无码mv在线观看网站| 高清在线亚洲精品国产二区| 色吊丝永久在线观看最新免费| 欧亚精品一区三区免费| 一色屋成人免费精品网站| 91精品国产免费久久久久久青草| 无码av免费网站| 99在线观看视频免费| 伊人久久免费视频| 最近免费字幕中文大全视频 | 亚洲AV日韩精品久久久久久 | 亚洲中文字幕久久久一区| 国产午夜亚洲精品| 亚洲欧美成aⅴ人在线观看| 亚洲国产成人久久精品大牛影视 | 免费一级毛片在播放视频| www.亚洲色图.com|