posts - 48, comments - 13, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          2009年1月5日

          spket - http://www.spket.com/update

          subclipse - http://subclipse.tigris.org/update

          posted @ 2010-12-02 09:39 董銳 閱讀(295) | 評論 (0)編輯 收藏

          Tomcat啟動時classloader加載順序
            Tomcat的class加載的優先順序一覽  
            1.最先是$JAVA_HOME/jre/lib/ext/下的jar文件。  
            2.環境變量CLASSPATH中的jar和class文件。  
            3.$CATALINA_HOME/common/classes下的class文件。  
            4.$CATALINA_HOME/commons/endorsed下的jar文件。  
            5.$CATALINA_HOME/commons/i18n下的jar文件。  
            6.$CATALINA_HOME/common/lib   下的jar文件。  
            (JDBC驅動之類的jar文件可以放在這里,這樣就可以避免在server.xml配置好數據源卻出現找不到JDBC   Driver的情況。)  
            7.$CATALINA_HOME/server/classes下的class文件。  
            8.$CATALINA_HOME/server/lib/下的jar文件。  
            9.$CATALINA_BASE/shared/classes   下的class文件。  
            10.$CATALINA_BASE/shared/lib下的jar文件。  
            11.各自具體的webapp   /WEB-INF/classes下的class文件。  
            12.各自具體的webapp   /WEB-INF/lib下的jar文件。

          posted @ 2010-11-03 11:31 董銳 閱讀(1014) | 評論 (0)編輯 收藏

          What this means is that leadership involves setting direction, communicating that vision passionately to those they work with, and helping the people they lead understand and commit to that vision. Managers, on the other hand, are responsible for ensuring that the vision is implemented efficiently and successfully.

          posted @ 2010-08-23 16:29 董銳 閱讀(451) | 評論 (0)編輯 收藏

          I know how to send by jquery post method $.post("test.php", { name: "John", time: "2pm" } );

          but what if my form field name is array

          <input type=text name="n1[]" id="n1[]" value='12345">   <input type=text name="n1[]" id="n1[]" value="14454">  

          how to send these 2 field value send to url by jquery post method?

           

          You can pass in an array as a value in the object:

          {name: 'John', 'nl[]': ['12345', '14454']}  

          (This is documented at ajax but also works for post.)

           

          var fields = $(":input").serializeArray();      $.post("test.php",fields);

          from:http://stackoverflow.com/questions/1656267/how-to-send-multi-field-value-by-jquery-post

          posted @ 2010-07-14 11:46 董銳 閱讀(741) | 評論 (0)編輯 收藏

          string.replace(new RegExp(oldString,"gm"),newString))

          posted @ 2010-07-14 11:20 董銳 閱讀(209) | 評論 (0)編輯 收藏

          在網上看到解決方案是把注冊表里(因為是windows操作系統)\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 下的NLS_lang 的NA值修改為SIMPLIFIED CHINESE_CHINA.ZHS16GBK;
           但是我在操作的時候,只把Oracle目錄下所有能找到的NLS_Lang值修改了,偏偏沒有修改Oracle目錄所對應的NLS_Lang值,導致一直測試不通過,始終報錯,最后終于發現原來Oracle目錄本身對應的NLS_lang值沒有修改,修改過后,測試通過,成功!

          posted @ 2010-01-14 14:45 董銳 閱讀(13497) | 評論 (2)編輯 收藏

          If you got this message: "Warning: Cannot modify header information - headers already sent by ...."
          如果在執行php程序時看到這條警告:"Warning: Cannot modify header information - headers already sent by ...."

          Few notes based on the following user posts:
          有以下幾種解決方法:

          1. Blank lines (空白行):
          Make sure no blank line after <?php ... ?> of the calling php script.
          檢查有<?php ... ?> 后面沒有空白行,特別是include或者require的文件。不少問題是這些空白行導致的。

           

           

          2. Use exit statement (用exit來解決):
          Use exit after header statement seems to help some people
          在header后加上exit();
          header ("Location: xxx");
          exit();

           

          3. PHP has this annoying problem, if your HTML goes before any PHP code or any header modification before redirecting to certain page, it'll said "Warning: Cannot modify header information - headers already sent by ...." Basically anytime you output to browser, the header is set and cannot be modified.   So two ways to get around the problem:

          3a. Use Javascript (用Javascript來解決):
          <? echo "<script> self.location(\"file.php\");</script>"; ?>
          Since it's a script, it won't modify the header until execution of Javascript.
          可以用Javascript來代替header。但是上面的這段代碼我沒有執行成功... 另外需要注意,采用這種方法需要瀏覽器支持Javascript.

          3b. Use output buffering (用輸出緩存來解決):
          <?php ob_start(); ?>
          ... HTML codes ...
          <?php
          ... PHP codes ...
          header ("Location: ....");
          ob_end_flush();
          ?>
          This will save the output buffer on server and not output to browser yet, which means you can modify the header all you want until the ob_end_flush() statement.   This method is cleaner than the Javascript since Javascript method assumes the browser has Javascript turn on.   However, there are overhead to store output buffer on server before output, but with modern hardware I would imagine it won't be that big of deal.   Javascript solution would be better if you know for sure your user has Javascript turn on on their browser.

          就像上面的代碼那樣,這種方法在生成頁面的時候緩存,這樣就允許在輸出head之后再輸出header了。


          ————————————————————————————————————————————
          結果最后還是這個問題:
          原來是php.ini里面的配置出了問題,output_buffering參數默認為off的,現在將它設為”on”就OK了。

          posted @ 2009-12-02 10:02 董銳 閱讀(7401) | 評論 (1)編輯 收藏

          1、要安裝java jdk,安裝tomcat
          2、安裝好apache,php
          3、下載php-java-bridge_5.5.4_documentation.zip
          4、解壓縮php-java-bridge_5.5.4_documentation.zip
          5、將解壓縮后根目錄下JavaBridge.war拷貝到tomcat服務器的webapp目錄下
          6、啟動tomcat服務器
          7、在php中使用java只需增加下面一行語句:
          <php? require_once(http://127.0.0.1:8080/JavaBridge/java/Java.inc); ?>

          可以了:
          <php?
              $date=new Java('java.util.Date');
          echo $date->getDate();
          ?>
          運行通過,OK!

          posted @ 2009-10-20 15:03 董銳 閱讀(587) | 評論 (2)編輯 收藏

          80端口被占用的解決方法:

          cmd命令窗口
          輸入netstat -abn ->c:/port80.txt
          然后到c盤port80.txt文件中找到占用80端口的程序pid,記下pid。打開任務管理器,點擊“查看”/選擇列,勾選“PID(進程標識符)”,然后單擊“進程”標簽,找到80端口對應的pid,就可以看到是那個程序占用的了,更改這個程序的port,再重啟這個程序,使更改生效。

          不管是Apache還是IIS都無法使用已被占用的端口。即每個端口只允許使用一次(一般指被一個服務程序所使用)。
          如果系統內已安裝IIS并使用了80端口(Http默認端口),再安裝Apache,只要另選一個端口并不與其他應用沖突即可運行。例如可以將Apache監聽的端口改為81或其他任何一個未被使用的端口。
          Apache修改監聽端口的方法為:
          打開 httpd.conf
          修改 Listen 80 為 Listen 81
          Apache可以同時監聽一個以上的端口實現多個Http服務
          只要添一行 如 Listen 82 即可

          posted @ 2009-09-24 14:18 董銳 閱讀(1220) | 評論 (0)編輯 收藏

          "^\d+$"  //非負整數(正整數 + 0)
          "^[0-9]*[1-9][0-9]*$"  //正整數
          "^((-\d+)|(0+))$"  //非正整數(負整數 + 0)
          "^-[0-9]*[1-9][0-9]*$"  //負整數
          "^-?\d+$"    //整數
          "^\d+(\.\d+)?$"  //非負浮點數(正浮點數 + 0)
          "^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"  //正浮點數
          "^((-\d+(\.\d+)?)|(0+(\.0+)?))$"  //非正浮點數(負浮點數 + 0)
          "^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"  //負浮點數
          "^(-?\d+)(\.\d+)?$"  //浮點數
          "^[A-Za-z]+$"  //由26個英文字母組成的字符串
          "^[A-Z]+$"  //由26個英文字母的大寫組成的字符串
          "^[a-z]+$"  //由26個英文字母的小寫組成的字符串
          "^[A-Za-z0-9]+$"  //由數字和26個英文字母組成的字符串
          "^\w+$"  //由數字、26個英文字母或者下劃線組成的字符串 //開源代碼OSPhP.COm.CN
          "^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$"    //email地址
          "^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$"  //url
          /^(d{2}|d{4})-((0([1-9]{1}))|(1[1|2]))-(([0-2]([1-9]{1}))|(3[0|1]))$/   //  年-月-日
          /^((0([1-9]{1}))|(1[1|2]))/(([0-2]([1-9]{1}))|(3[0|1]))/(d{2}|d{4})$/   // 月/日/年
          "^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$"   //Emil
          /^((\+?[0-9]{2,4}\-[0-9]{3,4}\-)|([0-9]{3,4}\-))?([0-9]{7,8})(\-[0-9]+)?$/     //電話號碼
          "^(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5])$"   //IP地址
          //開源OSPhP.COM.CN

          posted @ 2009-09-23 17:58 董銳 閱讀(216) | 評論 (0)編輯 收藏

          &:&amp;
          ": &quot;
          <url address="http://data.ent.sina.com.cn/star/starlist.php?&amp;initial=A&amp;tpl=0&amp;dpc=1"></url>
          <img tagText="p class=&quot;bigphoto&quot;" toExcelName="照片"></img>

          posted @ 2009-09-18 13:40 董銳 閱讀(148) | 評論 (0)編輯 收藏

          javascript從assiic轉字符:
          for(var i=65;i<91;i++)
             document.write("<a href='starlist.php?"+newsearch+"&initial="+String.fromCharCode(i)+"&tpl=0&dpc=1' target='_self'>"+String.fromCharCode(i)+"</a> ");

          posted @ 2009-09-15 10:05 董銳 閱讀(232) | 評論 (0)編輯 收藏

          DOM 是用與平臺和語言無關的方式表示 XML 文檔的官方 W3C 標準。DOM 是以層次結構組織的節點或信息片斷的集合。這個層次結構允許開發人員在樹中尋找特定信息。分析該結構通常需要加載整個文檔和構造層次結構,然后才能做任何工作。由于它是基于信息層次的,因而 DOM 被認為是基于樹或基于對象的。DOM 以及廣義的基于樹的處理具有幾個優點。首先,由于樹在內存中是持久的,因此可以修改它以便應用程序能對數據和結構作出更改。它還可以在任何時候在樹中上下導航,而不是像 SAX 那樣是一次性的處理。DOM 使用起來也要簡單得多。

            另一方面,對于特別大的文檔,解析和加載整個文檔可能很慢且很耗資源,因此使用其他手段來處理這樣的數據會更好。這些基于事件的模型,比如 SAX。
           
          這種處理的優點非常類似于流媒體的優點。分析能夠立即開始,而不是等待所有的數據被處理。而且,由于應用程序只是在讀取數據時檢查數據,因此不需要將數據存儲在內存中。這對于大型文檔來說是個巨大的優點。事實上,應用程序甚至不必解析整個文檔;它可以在某個條件得到滿足時停止解析。一般來說,SAX 還比它的替代者 DOM 快許多。


          JDOM 的目的是成為 Java 特定文檔模型,它簡化與 XML 的交互并且比使用 DOM 實現更快。由于是第一個 Java 特定模型,JDOM 一直得到大力推廣和促進。正在考慮通過“Java 規范請求 JSR-102”將它最終用作“Java 標準擴展”。從 2000 年初就已經開始了 JDOM 開發。

            JDOM 與 DOM 主要有兩方面不同。首先,JDOM 僅使用具體類而不使用接口。這在某些方面簡化了 API,但是也限制了靈活性。第二,API 大量使用了 Collections 類,簡化了那些已經熟悉這些類的 Java 開發者的使用。

            JDOM 文檔聲明其目的是“使用 20%(或更少)的精力解決 80%(或更多)Java/XML 問題”(根據學習曲線假定為 20%)。JDOM 對于大多數 Java/XML 應用程序來說當然是有用的,并且大多數開發者發現 API 比 DOM 容易理解得多。JDOM 還包括對程序行為的相當廣泛檢查以防止用戶做任何在 XML 中無意義的事。然而,它仍需要您充分理解 XML 以便做一些超出基本的工作(或者甚至理解某些情況下的錯誤)。這也許是比學習 DOM 或 JDOM 接口都更有意義的工作。

            JDOM 自身不包含解析器。它通常使用 SAX2 解析器來解析和驗證輸入 XML 文檔(盡管它還可以將以前構造的 DOM 表示作為輸入)。它包含一些轉換器以將 JDOM 表示輸出成 SAX2 事件流、DOM 模型或 XML 文本文檔。JDOM 是在 Apache 許可證變體下發布的開放源碼。 
                 http://www.jdom.org/


          最后是 DOM4J http://dom4j.sourceforge.net/

            雖然 DOM4J 代表了完全獨立的開發結果,但最初,它是 JDOM 的一種智能分支。它合并了許多超出基本 XML 文檔表示的功能,包括集成的 XPath 支持、XML Schema 支持以及用于大文檔或流化文檔的基于事件的處理。它還提供了構建文檔表示的選項,它通過 DOM4J API 和標準 DOM 接口具有并行訪問功能。從 2000 下半年開始,它就一直處于開發之中。

            為支持所有這些功能,DOM4J 使用接口和抽象基本類方法。DOM4J 大量使用了 API 中的 Collections 類,但是在許多情況下,它還提供一些替代方法以允許更好的性能或更直接的編碼方法。直接好處是,雖然 DOM4J 付出了更復雜的 API 的代價,但是它提供了比 JDOM 大得多的靈活性。

            在添加靈活性、XPath 集成和對大文檔處理的目標時,DOM4J 的目標與 JDOM 是一樣的:針對 Java 開發者的易用性和直觀操作。它還致力于成為比 JDOM 更完整的解決方案,實現在本質上處理所有 Java/XML 問題的目標。在完成該目標時,它比 JDOM 更少強調防止不正確的應用程序行為。

            DOM4J 是一個非常非常優秀的Java XML API,具有性能優異、功能強大和極端易用使用的特點,同時它也是一個開放源代碼的軟件。如今你可以看到越來越多的 Java 軟件都在使用 DOM4J 來讀寫 XML,特別值得一提的是連 Sun 的 JAXM 也在用 DOM4J。

          package com.test;

            import java.io.*;
            import java.util.*;
            import org.dom4j.*;
            import org.dom4j.io.*;

            public class MyXMLReader {

            public static void main(String arge[]) {
            long lasting = System.currentTimeMillis();
            try {
             File f = new File("data_10k.xml");
             SAXReader reader = new SAXReader();
             Document doc = reader.read(f);
             Element root = doc.getRootElement();
             Element foo;
             for (Iterator i = root.elementIterator("VALUE"); i.hasNext();) {
              foo = (Element) i.next();
              System.out.print("車牌號碼:" + foo.elementText("NO"));
              System.out.println(" 車主地址:" + foo.elementText("ADDR"));
             }
            } catch (Exception e) {
             e.printStackTrace();
            }
            System.out.println("運行時間:" + (System.currentTimeMillis() - lasting) + " 毫秒");
            }
            }

          posted @ 2009-09-08 13:38 董銳 閱讀(303) | 評論 (0)編輯 收藏

          配置tomcat的CATALINA_PATH,記得路徑后面不要帶上'\'或‘;’

          posted @ 2009-08-08 22:13 董銳 閱讀(159) | 評論 (0)編輯 收藏

              

          剛開始我將log4j.properties文件放在WEB-INF/目錄下,怎么都不能產生日志到文件中,后來才發現,原來要放到WEB-INF/classes目錄下才行。奇怪tapestry5為什么一定要這樣安排,不知有沒有什么地方是可以配置這個文件路徑的。

          posted @ 2009-04-28 06:26 董銳 閱讀(220) | 評論 (0)編輯 收藏

              
           <target name="build" description="Compile main source tree java files into class files, generate jar files">
             <javac destdir="${build.dir}"  listfiles="true"
              debug="true" deprecation="false" optimize="false" failonerror="true">
              <src path="${src.dir}"/>
              <classpath refid="master-classpath"/>
             </javac>
           </target>

          最近一個新項目運行這個target總是有問題,在目標路徑沒有類文件產生。后來發現每次要將該工程的bulidpath做點小變化,如remove哪個路勁再添加回去,讓工程重新bulid一下,在運行這個target就可以在目標路徑產生類文件了,好奇怪,不知為什么,之前幾個項目都是直接運行target就行了的。注:我用的是Eclipse開發工具。

          posted @ 2009-04-28 06:20 董銳 閱讀(925) | 評論 (2)編輯 收藏

          在tapestry5的頁面中,添加如下代碼
          @Inject
                  @Service("ApplicationGlobals")
                  private ApplicationGlobals applicationGlobals;

                  @SetupRender
                  void setListener(){
                          Clock.setListener(this);
                  }

          public void setClockDisplay(final String output) {

          Browser.withPage(ServerContextFactory.get(applicationGlobals.getServletContext()),"/manageCar/Dwrtracker", new Runnable() {
                      public void run() {
                         // Util.setValue("clockDisplay", output);
                      System.out.println("updateClockValue");
                          ScriptSessions.addFunctionCall("updateClockValue", output);
                 
                      }
                  });
          }
          interface IClockListener {
           public void setClockDisplay(final String output);
          }

          posted @ 2009-03-23 14:40 董銳 閱讀(292) | 評論 (0)編輯 收藏

           FROM :
          http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects


          import java.util.ArrayList;
          import java.util.Collection;
          import java.util.List;
          import org.apache.tapestry.OptionGroupModel;
          import org.apache.tapestry.OptionModel;
          import org.apache.tapestry.ValueEncoder;
          import org.apache.tapestry.internal.OptionModelImpl;
          import org.apache.tapestry5.internal.OptionGroupModelImpl;
          import org.apache.tapestry.ioc.services.PropertyAccess;
          import org.apache.tapestry.ioc.services.PropertyAdapter;
          import org.apache.tapestry.util.AbstractSelectModel;
          /** Generic selection model for a list of Objects.
          * use:
          * <pre>@Inject private PropertyAccess _access;</pre>
          * in your page to ge the {@link PropertyAccess} service.<br>
          * !Notice: you must set the created instance both as model and encoder parameter for the {@link Select} component.*/
          public class GenericSelectModel<T> extends AbstractSelectModel implements ValueEncoder<T> {
          private PropertyAdapter labelFieldAdapter;
          private PropertyAdapter idFieldAdapter;
          private Collection<T>         list;
          public GenericSelectModel(Collection<T> list, Class<T> clazz, String labelField, String idField, PropertyAccess access) {
          this.list = list;
          if (idField != null)
          this.idFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(idField);
          if (labelField != null)
          this.labelFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(labelField);
          }
          public void addOptionGroup(String label, boolean disabled, List<T> options) {
          List<OptionModel> optionModels = new ArrayList<OptionModel>();
          if (labelFieldAdapter == null) {
          for (T obj : options) {
          optionModels.add(new OptionModelImpl(nvl(obj), obj));
          }
          } else {
          for (T obj : options) {
          optionModels.add(new OptionModelImpl(nvl(labelFieldAdapter.get(obj)), obj));
          }
          }
          if (optionGroups == null) {
          optionGroups = new ArrayList<OptionGroupModel>();
          }
          optionGroups.add(new OptionGroupModelImpl(label, disabled, optionModels, new String[0]));
          }
          public List<OptionGroupModel> getOptionGroups() {
          return null;
          }
          public List<OptionModel> getOptions() {
          List<OptionModel> optionModelList = new ArrayList<OptionModel>();
          if (labelFieldAdapter == null) {
          for (T obj : list) {
          optionModelList.add(new OptionModelImpl(nvl(obj)));
          }
          } else {
          for (T obj : list) {
          optionModelList.add(new OptionModelImpl(nvl(labelFieldAdapter.get(obj)), obj));
          }
          }
          return optionModelList;
          }
          // ValueEncoder functions
          public String toClient(T obj) {
          if (idFieldAdapter == null) {
          return obj + "";
          } else {
          return idFieldAdapter.get(obj) + "";
          }
          }
          public T toValue(String string) {
          if (idFieldAdapter == null) {
          for (T obj : list) {
          if (nvl(obj).equals(string)) return obj;
          }
          } else {
          for (T obj : list) {
          if (nvl(idFieldAdapter.get(obj)).equals(string)) return obj;
          }
          }
          return null;
          }
          private String nvl(Object o) {
          if (o == null)
          return "";
          else
          return o.toString();
          }
          }
          

          posted @ 2009-03-15 22:20 董銳 閱讀(852) | 評論 (0)編輯 收藏

          轉自:http://www.nabble.com/sctx.getScriptSessionsByPage%28%29-problems-td19552209.html#a19552209

          Hi,

          Thanks for your response. So for the following code what is the updated
          version?

          CODE:

          Update/modify the calling client only:

             WebContext wctx = WebContextFactory.get();
             if(wctx != null)
             {
               Util utilThis = new Util(wctx.getScriptSession());
               utilThis.setValue("web Page Element Name", "Web Page Element Value");
             }


          import org.directwebremoting.ui.dwr.Util; /* i.e. NOT proxy.dwr.Util */
          Util.setValue("web Page Element Name", "Web Page Element Value");

           

           

          update all connected browsers viewing the relevant page:

           WebContext wctx = WebContextFactory.get();
           if (wctx != null)
           {
             String currentPage = wctx.getCurrentPage();
             Collection sessions = wctx.getScriptSessionsByPage(currentPage);
             Util utilAll = new Util(sessions);
             utilAll.addFunctionCall("createTable",tData);
           }

           


          final Object tData = ...;
          Browser.withCurrentPage(new Runnable() {
              public void run() {
                  ScriptSessions.addFunctionCall("createTable", tData);
              }
          });

           

           

          update all browsers for a specific page (non DWR started thread)

           servletContext = WebContextFactory.get().getServletContext();
           sctx = ServerContextFactory.get(servletContext);
           if (sctx != null)
           {
              Collection sessions = sctx.getScriptSessionsByPage("/stocksdemo/");
              Util utilAll = new Util(sessions);
              utilAll.addFunctionCall("function To Call","Data to pass");
           }

           


          Browser.withPage("/stocksdemo/",  new Runnable() {
              public void run() {

          posted @ 2009-03-14 22:19 董銳 閱讀(2911) | 評論 (0)編輯 收藏

          此篇文章甚好:
          http://www.ibm.com/developerworks/cn/java/j-jettydwr/index.html

          下載其示例代碼后,發現其使用的是dwr2.0.5的版本,
          現若要使用dwr3.0,需修改以下幾處代碼:
          ReverseAjaxTracker.java中:
          import org.directwebremoting.*;
          public ReverseAjaxTracker() {
              System.out.println("ReverseAjaxTracker");
            //  WebContext wctx = WebContextFactory.get();  這兩行注釋掉
            //  sctx = ServerContextFactory.get(wctx.getServletContext());

              RandomWalkGenerator.getInstance().addListener(this);
            }
          //OnCoord方法修改為如下幾句,原來的可全部注釋掉
          public void onCoord(final GpsCoord gpsCoord) {
              System.out.println("onCoord");
              Browser.withPage(mapPageUrl,  new Runnable() {
                  public void run() {
                      ScriptSessions.addFunctionCall("updateCoordinate",gpsCoord);
                  }
              });

          }

          就可以測試通過了!

          posted @ 2009-03-14 22:14 董銳 閱讀(280) | 評論 (0)編輯 收藏

          java.lang.ArrayIndexOutOfBoundsException
          7
          Stack trace
          • javassist.bytecode.StackMapTable$Walker.stackMapFrames(StackMapTable.java:192)
          • javassist.bytecode.StackMapTable$Walker.parse(StackMapTable.java:179)
          • javassist.bytecode.StackMapTable$Shifter.doit(StackMapTable.java:714)
          • javassist.bytecode.StackMapTable.shiftPc(StackMapTable.java:693)
          • javassist.bytecode.CodeIterator.insertGap0(CodeIterator.java:676)
          • javassist.bytecode.CodeIterator.insertGap(CodeIterator.java:636)
          • javassist.bytecode.CodeIterator.insertGapCore(CodeIterator.java:467)
          • javassist.bytecode.CodeIterator.insertGap(CodeIterator.java:413)
          • javassist.expr.Expr.replace0(Expr.java:298)
          • javassist.expr.FieldAccess.replace(FieldAccess.java:213)
          • org.apache.tapestry5.internal.services.InternalClassTransformationImpl$2.edit(InternalClassTransformationImpl.java:1739)
          • javassist.expr.ExprEditor.loopBody(ExprEditor.java:197)
          • javassist.expr.ExprEditor.doit(ExprEditor.java:90)
          • javassist.CtClassType.instrument(CtClassType.java:1289)
          • org.apache.tapestry5.internal.services.InternalClassTransformationImpl.replaceFieldAccess(InternalClassTransformationImpl.java:1745)
          • org.apache.tapestry5.internal.services.InternalClassTransformationImpl.performFieldTransformations(InternalClassTransformationImpl.java:1673)
          • org.apache.tapestry5.internal.services.InternalClassTransformationImpl.finish(InternalClassTransformationImpl.java:1336)
          • org.apache.tapestry5.internal.services.ComponentClassTransformerImpl.transformComponentClass(ComponentClassTransformerImpl.java:172)
          • org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl.onLoad(ComponentInstantiatorSourceImpl.java:201)
          • javassist.Loader.findClass(Loader.java:340)
          • org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass(ComponentInstantiatorSourceImpl.java:92)
          • javassist.Loader.loadClass(Loader.java:311)
          • java.lang.ClassLoader.loadClass(ClassLoader.java:252)
          • org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl.findClass(ComponentInstantiatorSourceImpl.java:292)
          • org.apache.tapestry5.internal.services.ComponentInstantiatorSourceImpl.findInstantiator(ComponentInstantiatorSourceImpl.java:272)
          • org.apache.tapestry5.internal.services.PageElementFactoryImpl.newRootComponentElement(PageElementFactoryImpl.java:262)
          • org.apache.tapestry5.internal.services.PageLoaderProcessor.loadRootComponent(PageLoaderProcessor.java:412)
          • org.apache.tapestry5.internal.services.PageLoaderProcessor.loadPage(PageLoaderProcessor.java:390)
          • org.apache.tapestry5.internal.services.PageLoaderImpl.loadPage(PageLoaderImpl.java:59)
          • org.apache.tapestry5.internal.services.PagePoolCache.checkout(PagePoolCache.java:210)
          • org.apache.tapestry5.internal.services.PagePoolImpl.checkout(PagePoolImpl.java:99)
          • org.apache.tapestry5.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:51)
          • org.apache.tapestry5.internal.services.RequestSecurityManagerImpl.checkForInsecureRequest(RequestSecurityManagerImpl.java:59)
          • org.apache.tapestry5.services.TapestryModule$35.handle(TapestryModule.java:1771)
          • org.apache.tapestry5.internal.services.PageRenderDispatcher.process(PageRenderDispatcher.java:92)
          • org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:71)
          • org.apache.tapestry5.services.TapestryModule$17.service(TapestryModule.java:1029)
          • cn.com.zzzz.store.services.AppModule$1.service(AppModule.java:88)
          • org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
          • org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
          • org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:621)
          • org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:611)
          • org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
          • org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
          • org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
          • org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
          • org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
          • org.apache.tapestry5.services.TapestryModule$16.service(TapestryModule.java:1007)
          • org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
          • org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
          • org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:179)
          • org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          • org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          • org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          • org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          • org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
          • org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          • org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          • org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
          • org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
          • org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
          • org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          • java.lang.Thread.run(Thread.java:619)


          ------------------------------------------------
          轉換.java文件時出錯,錯誤竟然是“超出數組邊界”,但文件中并沒有使用任何數組,百思不得其解。

          在此.java文件中有用到@ApplicationState  private User user;
          但沒有為user設置get和set方法,而是直接在.java文件中使用user=.....;

          后修改為加上user的get和set方法,在.java文件中用setUser(....); getUser().....

          上述錯誤解決,頁面順利顯示。

          posted @ 2009-03-14 19:27 董銳 閱讀(554) | 評論 (0)編輯 收藏

          Tapestry5ObtainingHttpServletRequest

          Tapestry encapsulates the HTTP servlet request, response and session, and you should not normally need to access them directly. However, sometimes it is necessary. For example, Acegi Security stores exception messages in the HttpSession.

          The underlying HTTP servlet mechanics are available via the [WWW] RequestGlobals service.

          Example

              @Inject
          private RequestGlobals requestGlobals;
          public void onActivate(Object context) {
          HttpSession session = requestGlobals.getHTTPServletRequest().getSession();
          ...
          }
          

          /!\ You need the servlet-api.jar in your classpath (dependency not included with tapestry quickstart).

          Alternatively, you can inject the HttpServletRequest directly (at least in 5.0.13):

              @Inject
          private HttpServletRequest _request;
          

          RequestGlobals is not accessible inside of AppModule.





          Copy From : http://wiki.apache.org/tapestry/Tapestry5ObtainingHttpServletRequest

          posted @ 2009-03-08 23:40 董銳 閱讀(557) | 評論 (0)編輯 收藏



          From:  http://wiki.apache.org/tapestry/Tapestry5HowToCreateYourOwnComponents

          posted @ 2009-03-08 23:27 董銳 閱讀(200) | 評論 (0)編輯 收藏

          Tapestry5的錯誤提示真的是非常詳細,它不但指出錯誤在哪?還會把正確的信息都列出來哦,下面的錯誤提示把所有可用的service都列出來了,非常方便!
          ------------
          @Inject
           @Service("HttpSession")
           private HttpSession session;
          此處出錯----------

          Defined services: ActionRenderResponseGenerator, AjaxComponentEventRequestHandler, AjaxComponentEventResultProcessor, AjaxPartialResponseRenderer, Alias, AliasOverrides, ApplicationDefaults, ApplicationGlobals, ApplicationInitializer, ApplicationStateManager, ApplicationStatePersistenceStrategySource, AspectDecorator, AssetBindingFactory, AssetObjectProvider, AssetSource, BSFServiceImpl, BaseURLSource, BeanBlockOverrideSource, BeanBlockSource, BeanModelSource, BindingSource, ChainBuilder, ClassNameLocator, ClasspathAssetAliasManager, ClasspathAssetFactory, ClasspathURLConverter, ClientPersistentFieldStorage, ClientPersistentFieldStrategy, ComponentClassCache, ComponentClassFactory, ComponentClassResolver, ComponentClassTransformWorker, ComponentClassTransformer, ComponentDefaultProvider, ComponentEventRequestHandler, ComponentEventResultProcessor, ComponentInstanceResultProcessor, ComponentInstantiatorSource, ComponentInvocationMap, ComponentMessagesSource, ComponentSource, ComponentTemplateSource, Context, ContextAssetFactory, ContextPathEncoder, ContextValueEncoder, CookieSink, CookieSource, Cookies, CtClassSource, DataTypeAnalyzer, DefaultDataTypeAnalyzer, DefaultFileItemFactory, DefaultHibernateConfigurer, DefaultImplementationBuilder, EndOfRequestListenerHub, Environment, EnvironmentalShadowBuilder, ExceptionAnalyzer, ExceptionTracker, FactoryDefaults, FieldTranslatorSource, FieldValidationSupport, FieldValidatorDefaultSource, FieldValidatorSource, FormSupport, FreeMarkerService, GoogleMapService, HibernateEntityPackageManager, HibernateSessionManager, HibernateSessionSource, HibernateTransactionDecorator, HiddenFieldLocationRules, HiveMind, HttpServletRequest, HttpServletRequestHandler, IgnoredPathsFilter, ImageServiceImpl, InjectionProvider, InternalRequestGlobals, JasperReportsService, LinkFactory, LocalizationSetter, LocationRenderer, LoggingDecorator, MarkupRenderer, MarkupWriterFactory, MasterDispatcher, MasterObjectProvider, MessageBindingFactory, MetaDataLocator, MultipartDecoder, NullFieldStrategyBindingFactory, NullFieldStrategySource, ObjectRenderer, PageActivationContextCollector, PageContentTypeAnalyzer, PageDocumentGenerator, PageElementFactory, PageLoader, PageMarkupRenderer, PagePool, PageRenderQueue, PageRenderRequestHandler, PageResourcesSource, PageResponseRenderer, PageTemplateLocator, PartialMarkupRenderer, PersistentFieldManager, PersistentLocale, PipelineBuilder, PropBindingFactory, PropertyAccess, PropertyConduitSource, PropertyShadowBuilder, RegistryStartup, RenderSupport, Request, RequestExceptionHandler, RequestGlobals, RequestHandler, RequestPageCache, RequestPathOptimizer, RequestSecurityManager, ResourceCache, ResourceDigestGenerator, ResourceStreamer, Response, ResponseRenderer, ServiceLifecycleSource, ServletApplicationInitializer, Session, SessionApplicationStatePersistenceStrategy, StrategyBuilder, SymbolSource, TemplateParser, ThreadLocale, ThumbnailService, TranslateBindingFactory, TranslatorSource, TypeCoercer, URIAssetAliasManager, URIAssetFactory, URLEncoder, UpdateListenerHub, ValidateBindingFactory, ValidationConstraintGenerator, ValidationMessagesSource, ValueEncoderSource, VelocityService, WebApplicationContext, applicationEventMulticaster, dataSource, messageSource, org.springframework.aop.config.internalAutoProxyCreator, org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0, productDao, productService, propertyConfigurer, sqlMapClient, transactionManager, txAdvice, user, userDao, userService.

          posted @ 2009-03-08 10:37 董銳 閱讀(330) | 評論 (0)編輯 收藏

          開始加入t5c-commons-0.5.18.jar時,一直不知道使用里面組件時前綴該如何寫,后來才知道org.apache.tapestry.commons包下TapestryCommonsModule類里 public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
              {
                  configuration.add(new LibraryMapping("t5components", "org.apache.tapestry.commons"));
                  configuration.add(new LibraryMapping("commons", "org.apache.tapestry.commons"));
              }
          這個地方定義了前綴。
          從這里可以看出,這個包下t5components和commons兩個前綴都可以用。
          <t:t5components/AjaxCheckbox></t:t5components/AjaxCheckbox>

          posted @ 2009-03-04 14:53 董銳 閱讀(176) | 評論 (0)編輯 收藏

          本來tapesty5有很精確的錯誤提示,但是我的怎么就沒有了呢?
          后來在網上找到這樣一句話:
          tapestry5有個production-mode,默認的為true,可以在作為產品發布時,提供精簡的錯誤信息,在開發時,異常信息當然是越精確越好,而且精確的異常信息也是tapestry的強項,可以很準確的告訴您錯誤出在哪里,所以在開發時這個選項要關掉,選中運行配置中的arguments標簽,在vm
          arguments中添加-Dtapestry.production-mode=false

          出處:http://tapestry.javaeye.com/blog/191803

          我于是在jvm arguments中添加了-Dtapestry.production-mode=false,果然可以了?。≈x謝這位仁兄!



          //////////////////////////////////////////////////////////////////////////////////
          上述問題的另外解決方法:不在jvm中添加參數,而是在service包下增加下面這個文件:


          import java.io.IOException;

          import org.apache.tapestry5.*;
          import org.apache.tapestry5.ioc.MappedConfiguration;
          import org.apache.tapestry5.ioc.OrderedConfiguration;
          import org.apache.tapestry5.ioc.ServiceBinder;
          import org.apache.tapestry5.ioc.annotations.Local;
          import org.apache.tapestry5.services.Request;
          import org.apache.tapestry5.services.RequestFilter;
          import org.apache.tapestry5.services.RequestHandler;
          import org.apache.tapestry5.services.Response;
          import org.slf4j.Logger;

          /**
           * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to
           * configure and extend Tapestry, or to place your own service definitions.
           */
          public class AppModule
          {
              public static void bind(ServiceBinder binder)
              {
                  // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
                 
                  // Make bind() calls on the binder object to define most IoC services.
                  // Use service builder methods (example below) when the implementation
                  // is provided inline, or requires more initialization than simply
                  // invoking the constructor.
              }
             
             
              public static void contributeApplicationDefaults(
                      MappedConfiguration<String, String> configuration)
              {
                  // Contributions to ApplicationDefaults will override any contributions to
                  // FactoryDefaults (with the same key). Here we're restricting the supported
                  // locales to just "en" (English). As you add localised message catalogs and other assets,
                  // you can extend this list of locales (it's a comma separated series of locale names;
                  // the first locale name is the default when there's no reasonable match).
                 
                  configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en,zh_cn");

                  // The factory default is true but during the early stages of an application
                  // overriding to false is a good idea. In addition, this is often overridden
                  // on the command line as -Dtapestry.production-mode=false
                  configuration.add(SymbolConstants.PRODUCTION_MODE, "false");//有了這句就不用加jvm arguments了
                  
                  configuration.add(SymbolConstants.COMPRESS_WHITESPACE, "false");
                  configuration.add(SymbolConstants.CHARSET, "UTF-8");
                 
              }
             

              /**
               * This is a service definition, the service will be named "TimingFilter". The interface,
               * RequestFilter, is used within the RequestHandler service pipeline, which is built from the
               * RequestHandler service configuration. Tapestry IoC is responsible for passing in an
               * appropriate Logger instance. Requests for static resources are handled at a higher level, so
               * this filter will only be invoked for Tapestry related requests.
               *
               * <p>
               * Service builder methods are useful when the implementation is inline as an inner class
               * (as here) or require some other kind of special initialization. In most cases,
               * use the static bind() method instead.
               *
               * <p>
               * If this method was named "build", then the service id would be taken from the
               * service interface and would be "RequestFilter".  Since Tapestry already defines
               * a service named "RequestFilter" we use an explicit service id that we can reference
               * inside the contribution method.
               */   
              public RequestFilter buildTimingFilter(final Logger log)
              {
                  return new RequestFilter()
                  {
                      public boolean service(Request request, Response response, RequestHandler handler)
                              throws IOException
                      {
                          long startTime = System.currentTimeMillis();

                          try
                          {
                              // The responsibility of a filter is to invoke the corresponding method
                              // in the handler. When you chain multiple filters together, each filter
                              // received a handler that is a bridge to the next filter.
                             
                              return handler.service(request, response);
                          }
                          finally
                          {
                              long elapsed = System.currentTimeMillis() - startTime;

                              log.info(String.format("Request time: %d ms", elapsed));
                          }
                      }
                  };
              }

              /**
               * This is a contribution to the RequestHandler service configuration. This is how we extend
               * Tapestry using the timing filter. A common use for this kind of filter is transaction
               * management or security. The @Local annotation selects the desired service by type, but only
               * from the same module.  Without @Local, there would be an error due to the other service(s)
               * that implement RequestFilter (defined in other modules).
               */
              public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
                      @Local
                      RequestFilter filter)
              {
                  // Each contribution to an ordered configuration has a name, When necessary, you may
                  // set constraints to precisely control the invocation order of the contributed filter
                  // within the pipeline.
                 
                  configuration.add("Timing", filter);
              }
          }


          posted @ 2009-03-04 13:59 董銳 閱讀(520) | 評論 (0)編輯 收藏

          <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <title>加上面這句才支持中文</title>
          </head>
          <body>
          加上面這句才支持中文
          </body>
          </html>


          /////////////////////////////////


          import java.io.IOException;

          import org.apache.tapestry5.*;
          import org.apache.tapestry5.ioc.MappedConfiguration;
          import org.apache.tapestry5.ioc.OrderedConfiguration;
          import org.apache.tapestry5.ioc.ServiceBinder;
          import org.apache.tapestry5.ioc.annotations.Local;
          import org.apache.tapestry5.services.Request;
          import org.apache.tapestry5.services.RequestFilter;
          import org.apache.tapestry5.services.RequestHandler;
          import org.apache.tapestry5.services.Response;
          import org.slf4j.Logger;

          /**
           * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to
           * configure and extend Tapestry, or to place your own service definitions.
           */
          public class AppModule
          {
              public static void bind(ServiceBinder binder)
              {
                  // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
                 
                  // Make bind() calls on the binder object to define most IoC services.
                  // Use service builder methods (example below) when the implementation
                  // is provided inline, or requires more initialization than simply
                  // invoking the constructor.
              }
             
             
              public static void contributeApplicationDefaults(
                      MappedConfiguration<String, String> configuration)
              {
                  // Contributions to ApplicationDefaults will override any contributions to
                  // FactoryDefaults (with the same key). Here we're restricting the supported
                  // locales to just "en" (English). As you add localised message catalogs and other assets,
                  // you can extend this list of locales (it's a comma separated series of locale names;
                  // the first locale name is the default when there's no reasonable match).
                 
                  configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en,zh_cn");

                  // The factory default is true but during the early stages of an application
                  // overriding to false is a good idea. In addition, this is often overridden
                  // on the command line as -Dtapestry.production-mode=false
                  configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
                 
                  configuration.add(SymbolConstants.COMPRESS_WHITESPACE, "false");
                  configuration.add(SymbolConstants.CHARSET, "UTF-8");//有了這句不知是不是可以不要用上面那句了,還沒試過
                  
              }
             

              /**
               * This is a service definition, the service will be named "TimingFilter". The interface,
               * RequestFilter, is used within the RequestHandler service pipeline, which is built from the
               * RequestHandler service configuration. Tapestry IoC is responsible for passing in an
               * appropriate Logger instance. Requests for static resources are handled at a higher level, so
               * this filter will only be invoked for Tapestry related requests.
               *
               * <p>
               * Service builder methods are useful when the implementation is inline as an inner class
               * (as here) or require some other kind of special initialization. In most cases,
               * use the static bind() method instead.
               *
               * <p>
               * If this method was named "build", then the service id would be taken from the
               * service interface and would be "RequestFilter".  Since Tapestry already defines
               * a service named "RequestFilter" we use an explicit service id that we can reference
               * inside the contribution method.
               */   
              public RequestFilter buildTimingFilter(final Logger log)
              {
                  return new RequestFilter()
                  {
                      public boolean service(Request request, Response response, RequestHandler handler)
                              throws IOException
                      {
                          long startTime = System.currentTimeMillis();

                          try
                          {
                              // The responsibility of a filter is to invoke the corresponding method
                              // in the handler. When you chain multiple filters together, each filter
                              // received a handler that is a bridge to the next filter.
                             
                              return handler.service(request, response);
                          }
                          finally
                          {
                              long elapsed = System.currentTimeMillis() - startTime;

                              log.info(String.format("Request time: %d ms", elapsed));
                          }
                      }
                  };
              }

              /**
               * This is a contribution to the RequestHandler service configuration. This is how we extend
               * Tapestry using the timing filter. A common use for this kind of filter is transaction
               * management or security. The @Local annotation selects the desired service by type, but only
               * from the same module.  Without @Local, there would be an error due to the other service(s)
               * that implement RequestFilter (defined in other modules).
               */
              public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
                      @Local
                      RequestFilter filter)
              {
                  // Each contribution to an ordered configuration has a name, When necessary, you may
                  // set constraints to precisely control the invocation order of the contributed filter
                  // within the pipeline.
                 
                  configuration.add("Timing", filter);
              }
          }

          posted @ 2009-03-04 10:38 董銳 閱讀(899) | 評論 (1)編輯 收藏

        1. java.lang.ClassNotFoundException
          caught an exception while obtaining a class file for cn.com.eTrans.manageCar.pages.Login
          exception
          org.apache.tapestry5.internal.services.TransformationException: javassist.NotFoundException: org.apache.tapestry.commons.components.AjaxCheckbox
        2. org.apache.tapestry5.internal.services.TransformationException
          javassist.NotFoundException: org.apache.tapestry.commons.components.AjaxCheckbox

        3. 這個問題我想了好久,也盯著它看了好久,我真是不解,org.apache.tapestry.commons.components.AjaxCheckbox明明就在那,怎么會找不到呢?

          后來終于找到原因了:
          沒有將t5c-commons-0.5.18.jar包放在web-info/lib下?。。?!
          tapestry5是按自己的方式找文件的,不在web-info在的找不到!?。?!

          posted @ 2009-02-27 18:00 董銳 閱讀(153) | 評論 (0)編輯 收藏

          java.lang.IllegalArgumentException
          Unable to resolve 't5components/AjaxCheckbox' to a component class name. Available component types: ActionLink, AddRowLink, AjaxFormLoop, Any, BeanDisplay, BeanEditForm, BeanEditor, Checkbox, DateField, Delegate, Errors, EventLink, ExceptionDisplay, Form, FormFragment, FormInjector, Grid, GridCell, GridColumns, GridPager, GridRows, If, Label, LinkSubmit, Loop, Output, OutputRaw, PageLink, Palette, PasswordField, PropertyDisplay, PropertyEditor, Radio, RadioGroup, RemoveRowLink, RenderObject, Select, Submit, SubmitNotifier, TextArea, TextField, TextOutput, Unless, Zone.



          如何解決?待續

          后來終于找到原因了:
          沒有將t5c-commons-0.5.18.jar包放在web-info/lib下!?。?!
          tapestry5是按自己的方式找文件的,不在web-info在的找不到?。。?!

          posted @ 2009-02-27 14:13 董銳 閱讀(553) | 評論 (0)編輯 收藏

          記錄下載安裝及破解所查看的一些網站和資料:

              rational rose下載:

            http://tseg.org/~dxiao/SEPractice/Rational2003/RationalRoseEnterpriseEditionforWindows.2003.06.00.391.000.exe

          1.安裝Rose,默認是需要許可證書的..去下載個破解的..
          http://www.cnblogs.com/Files/lixianhuei/rose2003crack.rar
          2.先用破解壓縮包里的 rational.exe,lmgrd.exe 覆蓋到你的 \安裝目錄的Rartional\commen\

          3.然后記事本打開 license.dat, 修改里面的 SERVER yourPC ANY DAEMON rational "C:\Program Files\Rational\Common\rational.exe"
          改成 SERVER 你的機器名 ANY DAEMON rational "你的安裝目錄\rational.exe" ,拷貝到Common目錄下..

          4. Flexlm.cpl拷貝到C:\winnt\system32\下, 在控制面板里運行 FlexLm License Manager,
          運行后, Setup 面板配置文件路徑,lmgrd.exe -> 你的安裝目錄 \Common\lmgrd.exe, License File 為你改過的 license.dat ...

          (我用的是xp,目錄為C:\WINDOWS\system32


          5.
          Control面板點擊Start,如果成功的話點擊Status按鈕將顯示 你的機器名:license server UP (MASTER) 說明成功了
          失敗的話重啟一下FlexLm License Manager就沒問題了。

          6.如果彈出對話框License Key Administrator Wizard, 選定Point to a Rational License Server to get my licenses,單擊下一步,
          Server Name
          文本框中填寫你的機器號(可能已經填好),單擊完成。 (成功的話會出現兩屏的licenses)

          posted @ 2009-02-22 14:43 董銳 閱讀(670) | 評論 (0)編輯 收藏

          下載apache-maven-2.0.9-bin軟件包,在path里加上了bin路徑,運行mvn -version總是出現java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher 的錯誤,重新下載了maven-2.0.5-bin.zip將path路徑改為\maven-2.0.5-bin\maven-2.0.5\bin,并增加了一個M2_HOME路徑\maven-2.0.5-bin\maven-2.0.5,再次運行成功!在\maven-2.0.5-bin\maven-2.0.5\core\boot 路徑下classworlds-1.1.jar包里就有要找的文件org.codehaus.classworlds.Launcher!

          posted @ 2009-02-17 14:33 董銳 閱讀(6148) | 評論 (0)編輯 收藏

          在tapestry4中使用了session值,要記得在pageBeginRender中第一次進入清空,其后不需清空。

          posted @ 2009-02-13 17:10 董銳 閱讀(144) | 評論 (0)編輯 收藏

          什么是Tapestry?
          歡迎來到Tapestry世界!
          本文是一篇幫助人們使用Tapestry5來創建應用程序的指導文章。不論你是否會使用Tapestry4(或Tapestry3)或者你對Tapestry完全陌生,都不影響你閱讀此篇指南,事實上你對一般的互聯網程序開發知道的越少,Tapestry則對你是越好的選擇,因為你可以少學很多!
            當然你還是需要知道以下一些知識:HTML、XML,基本的Java語言特性和一些新一點的東西如Java Annotations.
          如果你是用servlets、JSP或Struts來開發互聯網應用程序的,或許你已對很多麻煩的事情習以為常了?;蛟S你并沒有意識到你所處的可怕處境。這些環境沒有安全保障;Struts和Servlet API不知道你程序的架構是如何的,不知道各個不同的塊是如何連接起來的。任何一個URL地址都可以是一個Action并且每個Action都可以前進到任何一個顯示頁面(通常是JSP頁面),這些顯示頁面會生成返回到客戶端瀏覽器的HTML頁面。作為一個開發者,你必須要做出一系列永無止盡的小而重要的決定(并且要與你的開發團隊進行協商),如actions、頁面、屬性等的命名規范、變量存放在HttpSession中還是存放在HttpServletRequest中等等,這些都是麻煩的事情。
          傳統方式將很多你不想要的東西推向你:多線程編程。還記得以前學習面向對象編程?一個對象可以定義為一組數據以及對這些數據進行操作的集合?當你開始互聯網編程后你就必須忘記這個課程,因為互聯網編程是多線程的。一個應用服務器可以處理來自單個用戶的幾十、上百個請求,每一個用戶都有自己的線程,而且每一個用戶都共享相同的對象。 突然,你發現不能在一個對象(一個servlet或一個struts Action)中存儲數據,因為不論你為一個用戶存放什么數據,它都會立馬被某個其他用戶的數據覆蓋。
          更糟的是,你的每個對象都有一個方法:doGet()或doPost()。
          期間你每天工作的大部分內容是決定如何將你已經存儲在java對象中的數據給打包然后把這些數據擠壓進一個URL地址的請求參數里,然后你得再寫些代碼把這些數據給轉換回來。同時要記得修改一大堆存儲在servlet容器或Struts框架中的XML文件,讓它們知道這些決定。

          posted @ 2009-02-05 15:03 董銳 閱讀(220) | 評論 (0)編輯 收藏

          22 <component id="aPersonSelect" type="PropertySelection">
          23 <binding name="model" value="ognl:personSelectModel"/>
          24 <binding name="value" value="ognl:components.table.tableRow.aPerson"/>
          25 </component>

          ognl:OgnlException:source is null for getProperty(null, "aPerson")

          錯誤描述:這是一個component中一個表A,還有一個表B,最初是表A顯示,表B隱藏,顯示沒有問題,然后點擊component中一個按鈕,隱藏表A,顯示表B,就出現這樣的錯誤。

          判斷1:以為表A的數據源沒有在Session保存,導致點擊按鈕重新裝載頁面時數據源為空,所以出現此錯誤,就將數據源改為session狀態,還是有此錯誤
          判斷2:表A和表B是共用同一數據源,只是Column值有變化,修改為只用一個表,點擊按鈕時setColumn賦不同值,測試發現點擊后表格內容沒有變化,賦Column值失敗
          判斷3:還是表A和表B,此次表A和表B使用不同數據源變量,點擊按鈕時表A數據表中內容選取部分賦給表B數據源,點擊按鈕,依然出現上述錯誤。

          錯誤未解決:
          待續。。。
          -------------------------------------------
          判斷4:<td jwcid="aPersonColumnValue@Block"><span jwcid="aPersonSelect" /></td>
          在.html文件中屏蔽此句,沒有錯誤。
          ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          終于找到錯誤原因了:
          原來表A和表B的列名相同,都用了aPerson,所以當顯示表B時,為表A所用的<td jwcid="aPersonColumnValue@Block"><span jwcid="aPersonSelect" /></td>也為表B所用了,而表B的aPerson用的是:aPerson:aPerson.name,所以每次獲取aPerson值都為空,修改表B的column為aPerson1:aPerson.name即成功!!
          找了這么久,原來是這個錯誤,汗!?。。?br />

          posted @ 2009-02-01 10:57 董銳 閱讀(222) | 評論 (0)編輯 收藏

          如果propertySelection中是復雜對象,一定記得要重載public boolean equals(Object obj)方法才可以順利選中初始值哦!

          posted @ 2009-01-22 18:07 董銳 閱讀(175) | 評論 (0)編輯 收藏

          http://tapestry.apache.org/tapestry5/guide/persist.html

          Most instance variables in Tapestry are automatically cleared at the end of each request.
          通常每次請求結束,Tapestry會將實例變量清空。

          This is important, as it pertains to how Tapestry pages are pooled and shared, over time, by many users.
          這很重要,因為Tapestry的頁面是在緩沖池中被許多用戶共享的。

          However, you often want to store some persistent data on a page, and have access to it in later requests.
          然而,你通常希望在頁面存儲一些持久數據,這樣后面的請求可以得到這些數據。

          This is accomplished with the Persist annotation.

          This annotation is applied to private instance fields.

            @Persist
          private int value;

          Annotated fields will store their state between requests. Generally, speaking, this means that the value is stored into the session (but other approaches are possible).

          Whenever you make a change to a persistent field, its value is stored.

          On later requests, the value for such persistent fields is reloaded from storage.



          Persistence Strategies

          The value for each field is the strategy used to store the field between requests.

          session strategy

          The session strategy stores field changes into the session; the session is created as necessary.

          A suitably long session attribute name is used; it incorporates the name of the page, the nested component id, and the name of the field.

          Session strategy is the default strategy used unless otherwise overridden.

          Session策略是默認策略。

          flash strategy

          The flash strategy stores information in the session as well, just for not very long. Values are stored into the session, but then deleted from the session as they are first used to restore a page's state.

          The flash is typically used to store temporary messages that should only be displayed to the user once.

          client strategy

          The field is persisted onto the client; you will see an additional query parameter in each URL (or an extra hidden field in each form).


          Client  持久花費的代價要高些,它會在渲染頁面的每個鏈接后面加上數百字節的額外信息。

          Client persistence is somewhat expensive. It can bloat the size of the rendered pages by adding hundreds of characters to each link. There is extra processing on each request to de-serialize the values encoded into the query parameter.

          Client persistence does not scale very well; as more information is stored into the query parameter, its length can become problematic. In many cases, web browsers, firewalls or other servers may silently truncate the URL which will break the application. 有時URL地址太長會被截掉。

          Use client persistence with care, and store a minimal amount of data. Try to store the identity (that is, primary key) of an object, rather than the object itself.

          posted @ 2009-01-21 16:49 董銳 閱讀(221) | 評論 (0)編輯 收藏

          Iterative Development and the unified process
          People are more important than any process.
          Good people with a good process will outperform good people with no process every time.
                  --Grady Booch

          Case Study: The NextGen PosSystem
          Few things are harder to put up with than a good example.
                  --Mark Twain

          Inception
          The best is the enemy of the good!
                  --Voltaire

          Understanding requirements
          Ours is a world where people don't know what they want and are willing to go through hell to get it.
                  --Don Marquis

          Use-Case Model: Writing requirements in Context
          The indispensable first step to getting the things you want out of life:decide what you want.
                  --Ben Stein

          Identifying other requirements
          When ideas fail, words come in very handy.
                  --Johann Wolfgang von Goethe

          From inception to elaboration
          The hard and stiff breaks. The supple prevails.
                  --Tao Te Ching

          Use-Case Model: Drawing System Sequence Diagrams
          In theory, there is no difference between theory and practice. But, in practice, there is.
                  --Jan L.A. van de Snepscheut

          Domain Model: Visualizing Concepts
          It's all very well in practice, but it will never work in theory.
                  --anonymous management maxim

          Domain Model: Adding Attributes
          Any sufficiently advanced bug is indistinguishable from a feature.
                  --Rich Kulawiec

          Use-Case Model: Adding Detail With Operation Contracts
          Fast, Cheap, Good: Choose any two.
              --anonymous

          From Requirements to Design in this iteration
          Hardware,n.: The parts of a computer system that can be kicked.
              --anonymous

          Iteration Diagram Notation
           Cats are smarter than dogs. You can't get eight cats to pull a sled through snow.
              --Jeff Valdez

          GRASP:Designing Objects with responsibilities
          The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
              --Nathaniel Borenstein

          Design Model: Use-Case Realizations With GRASP Patterns
          To invent, you need a good imagination and a pile of junk.
              --Thomas Edison

          Design Model: Determining Visibility
          A mathematician is a device for turning coffee into theorems.
              --Paul Erdos

          Design Model: Creating Design Class Diagrams
          To iterate is human, to recurse, divine.
              --anonymous

          Implementation Model: Mapping Designs To Code
          Beware of bugs in the above code; I have only proved it correct, not tried it.
              --Donald Knuth

          GRASP:More patterns for assigning responsibilities
          Luck is the residue of design.
              --Branch Rickey

          Designing Use-Case Realizations with GoF Design Patterns
          Anything you can do, I can do meta.
                  --Daniel Dennett

          Relating Use Cases
          Why do programmers get Halloween and Christmas mixed up? Because OCT(31)=DEC(25)

          Modeling Generalization
          Crude classifications and false generalizations are the curse of the organized life.
              --A generalization by H.G.Wells

          Refining the Domain Model
          PRESENT, n. That part of eternity dividing the domain of disappointment from the realm of hope.
              --Ambrose Bierce

          Adding new SSDs and Contracts
          Virtue is insufficient temptation.
              --George Bernard Shaw

          Modeling Behavior in statechart diagrams
          Usability is like oxygen--you never notice it until it is missing.
            --anonymous

          Designing the logical architecture with patterns
          0x2B | ~0x2B
                  --Hamlet

          Organizing the design and implementation model packages
          If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens?
              --Seymour Cray

          Introduction To Architectual Analysis and the SAD
          Error, no keyboard ~ press F1 to continue.
              --early PC BIOS message

          Designing more use-case realizations with objects and patterns
          On two occasions I have been asked (by memebers of Parliament), "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehand the kind of confusion of ideas that could provoke such a question.
               --Charles Babbage

          Designing  a persistence framework with patterns
          Time is a good teacher, but unfortunately it kills all its pupils.
              --Hector Berlioz

          On drawing and tools
          Bubbles don't crash.
            --Bertrand Meyer

          Introduction to iterative planning and project isssues
          Prediction is very difficult, especially if it's about the future.
              --anonymous

          Comments on Iterative Development and the UP
          You should use iterative development only on projects that you want to succeed.
              --Martin Fowler

          posted @ 2009-01-19 03:59 董銳 閱讀(212) | 評論 (0)編輯 收藏

              Analysis: do the right thing;
              Design: do the thing right!

          posted @ 2009-01-19 03:10 董銳 閱讀(114) | 評論 (0)編輯 收藏

          今天中午急著打個新包發布,但是怎么打都打不成功,同樣的build.xml,在自機器上運行也沒有問題,怎么就打不成功呢,雖然知道不成功是因為class沒有編譯全,也就是說有一個java文件有問題,導致編譯不全,但我在eclipse下把個各包是看了又看,沒發現哪里有紅叉叉啊,eclipse下沒有紅叉叉,但又編譯有問題,我真是想不明白,越是急越是想不明白。
          最后終于通過查看到底少了哪些class來逐個查看,終于找到那個問題文件了,打開那個文件,很明顯的有個紅條條顯示問題在哪里,但是這個文件在eclipse目錄下卻沒有紅叉叉,本來文件里有紅條條,對應目錄應該有紅叉叉,但是這個不知為什么沒有,真是奇怪,算不算eclipse的BUG呢?

          posted @ 2009-01-12 14:23 董銳 閱讀(110) | 評論 (0)編輯 收藏

          其他同事瀏覽器顯示都正常,就只有一個同事顯示為空白,瀏覽器下方狀態欄里多了一個小黃色三角!(感嘆)符號,點開來是IE管理加載項的界面。
          這個同事禁用了很多加載項,后來一個一個試,將Shockwave Flash Object設為啟用后,頁面就可以正常顯示了。
          這個頁面唯一不同與其他的頁面的地方是它加載了dojo.js文件,我估計是dojo.js文件里有用到Shockwave Flash Object里的東西。
          看來,有用到dojo.js的朋友需要注意了,要啟用Shockwave Flash Object加載才能正常顯示哦??! 

          posted @ 2009-01-09 13:15 董銳 閱讀(1484) | 評論 (3)編輯 收藏

          原來原因在這里:
          css文件里font-family: "黑體";這句導致后面的css定義全部不起作用了。
          只要把font-family: "黑體";
          改成
          font-family:黑體;
          就行了,去掉空格和雙引號。
          這個問題只存在于IE6中。
           


          posted @ 2009-01-05 17:45 董銳 閱讀(2140) | 評論 (1)編輯 收藏

              由于服務器上之前已安裝Confluence, 它已自帶了tomcat1.5。
          而我想在服務器上再啟用tomcat1.6,發布我的包。我用的是解壓版。
          在網上看了很多改端口的設置,在server.xml中將所有端口+1后,運行startup.bat,發現啟動的還是tomcat1.5。
          于是我修改了startup.bat,終于成功啟動tomcat1.6了,以下紅色標注的是修改的地方:

          @echo off
          rem Licensed to the Apache Software Foundation (ASF) under one or more
          rem contributor license agreements.  See the NOTICE file distributed with
          rem this work for additional information regarding copyright ownership.
          rem The ASF licenses this file to You under the Apache License, Version 2.0
          rem (the "License"); you may not use this file except in compliance with
          rem the License.  You may obtain a copy of the License at
          rem
          rem     http://www.apache.org/licenses/LICENSE-2.0
          rem
          rem Unless required by applicable law or agreed to in writing, software
          rem distributed under the License is distributed on an "AS IS" BASIS,
          rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          rem See the License for the specific language governing permissions and
          rem limitations under the License.

          if "%OS%" == "Windows_NT" setlocal
          rem ---------------------------------------------------------------------------
          rem Start script for the CATALINA Server
          rem
          rem $Id: startup.bat 562770 2007-08-04 22:13:58Z markt $
          rem ---------------------------------------------------------------------------

          rem Guess CATALINA_HOME if not defined
          set CURRENT_DIR=%cd%
          rem# if not "%CATALINA_HOME%" == "" goto gotHome//
          set CATALINA_HOME=%CURRENT_DIR%
          set JAVA_HOME="C:\Sun\SDK\jdk"
          if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
          cd ..
          set CATALINA_HOME=%cd%
          cd %CURRENT_DIR%
          :gotHome
          if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
          echo The CATALINA_HOME environment variable is not defined correctly
          echo This environment variable is needed to run this program
          goto end
          :okHome

          set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat

          rem Check that target executable exists
          if exist "%EXECUTABLE%" goto okExec
          echo Cannot find %EXECUTABLE%
          echo This file is needed to run this program
          goto end
          :okExec

          rem Get remaining unshifted command line arguments and save them in the
          set CMD_LINE_ARGS=
          :setArgs
          if ""%1""=="""" goto doneSetArgs
          set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
          shift
          goto setArgs
          :doneSetArgs

          call "%EXECUTABLE%" start %CMD_LINE_ARGS%

          :end


          posted @ 2009-01-05 10:09 董銳 閱讀(2374) | 評論 (0)編輯 收藏

          在Eclipse下打開Window-preference,點擊ant,鉤中 create problem markers from "javac" results

          在bulid.xml中配置紅色屬性就行了。

          <project name="YGKH" default="help" basedir="." >

           <property name="build.dir" value="WEB-INF/classes"/>
           <property name="lib.dir" value="WEB-INF/lib"/>
           <property name="src.dir" value="src"/>
           
           <target name="help">
            <echo>
            This script requires Ant 1.5 or higher

            usage:
               ant -help  display ant help screen
               ant help   display this message
               ant clean  delete the built directory
               ant war   war
            </echo>
           </target>
           <path id="master-classpath">
            <fileset dir="${lib.dir}">
              <include name="*.jar"/>
            </fileset>
           </path>
           <target name="clean">
            <delete file="${war.file}" quiet="true"/>
            <delete dir="${build.dir}"/>
           </target>


           <target name="build" description="Compile main source tree java files into class files, generate jar files">

             <mkdir dir="${build.dir}"/>

             <javac destdir="${build.dir}"  listfiles="true"
              debug="true" deprecation="false" optimize="false" failonerror="true">
              <src path="${src.dir}"/>
              <classpath refid="master-classpath"/>
             </javac>
             <copy todir="${build.dir}" preservelastmodified="true">
               <fileset dir="${src.dir}">
                <include name="**/*.xml"/>
               </fileset>
             </copy>
           </target>

           <target name="war" depends="build">
            <war warfile="YGKH.war" webxml="WEB-INF/web.xml">
             <fileset dir="../YGKH">
              <include name="images/**"/>
              <include name="WEB-INF/**"/>
              <include name="css/**"/>
              <include name="js/**"/>
              <include name="*.html"/>
             </fileset>
             
            </war>
           </target>
           <target name="all" depends="clean,build,war" description="Clean,build,war"/>
          </project>

          posted @ 2009-01-05 10:03 董銳 閱讀(698) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 浮山县| 吉木乃县| 专栏| 沽源县| 区。| 开封县| 阳朔县| 剑河县| 和平县| 越西县| 湖北省| 高淳县| 长岭县| 秦安县| 五峰| 镇平县| 如东县| 白银市| 读书| 隆尧县| 册亨县| 新龙县| 克什克腾旗| 犍为县| 鄂州市| 桃园县| 龙口市| 三亚市| 麻阳| 额尔古纳市| 双峰县| 黔西县| 滦南县| 博白县| 定西市| 沾益县| 织金县| 林州市| 保德县| 清水河县| 无锡市|