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

          2009年2月22日

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

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

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

          Tomcat啟動時(shí)classloader加載順序
            Tomcat的class加載的優(yōu)先順序一覽  
            1.最先是$JAVA_HOME/jre/lib/ext/下的jar文件。  
            2.環(huán)境變量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驅(qū)動之類的jar文件可以放在這里,這樣就可以避免在server.xml配置好數(shù)據(jù)源卻出現(xiàn)找不到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 董銳 閱讀(1013) | 評論 (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 董銳 閱讀(450) | 評論 (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 董銳 閱讀(740) | 評論 (0)編輯 收藏

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

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

          在網(wǎng)上看到解決方案是把注冊表里(因?yàn)槭莣indows操作系統(tǒng))\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 下的NLS_lang 的NA值修改為SIMPLIFIED CHINESE_CHINA.ZHS16GBK;
           但是我在操作的時(shí)候,只把Oracle目錄下所有能找到的NLS_Lang值修改了,偏偏沒有修改Oracle目錄所對應(yīng)的NLS_Lang值,導(dǎo)致一直測試不通過,始終報(bào)錯(cuò),最后終于發(fā)現(xiàn)原來Oracle目錄本身對應(yīng)的NLS_lang值沒有修改,修改過后,測試通過,成功!

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

          If you got this message: "Warning: Cannot modify header information - headers already sent by ...."
          如果在執(zhí)行php程序時(shí)看到這條警告:"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的文件。不少問題是這些空白行導(dǎo)致的。

           

           

          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。但是上面的這段代碼我沒有執(zhí)行成功... 另外需要注意,采用這種方法需要瀏覽器支持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.

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


          ————————————————————————————————————————————
          結(jié)果最后還是這個(gè)問題:
          原來是php.ini里面的配置出了問題,output_buffering參數(shù)默認(rèn)為off的,現(xiàn)在將它設(shè)為”on”就OK了。

          posted @ 2009-12-02 10:02 董銳 閱讀(7400) | 評論 (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服務(wù)器的webapp目錄下
          6、啟動tomcat服務(wù)器
          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();
          ?>
          運(yùn)行通過,OK!

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

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

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

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

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

          "^\d+$"  //非負(fù)整數(shù)(正整數(shù) + 0)
          "^[0-9]*[1-9][0-9]*$"  //正整數(shù)
          "^((-\d+)|(0+))$"  //非正整數(shù)(負(fù)整數(shù) + 0)
          "^-[0-9]*[1-9][0-9]*$"  //負(fù)整數(shù)
          "^-?\d+$"    //整數(shù)
          "^\d+(\.\d+)?$"  //非負(fù)浮點(diǎn)數(shù)(正浮點(diǎn)數(shù) + 0)
          "^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"  //正浮點(diǎn)數(shù)
          "^((-\d+(\.\d+)?)|(0+(\.0+)?))$"  //非正浮點(diǎn)數(shù)(負(fù)浮點(diǎn)數(shù) + 0)
          "^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"  //負(fù)浮點(diǎn)數(shù)
          "^(-?\d+)(\.\d+)?$"  //浮點(diǎn)數(shù)
          "^[A-Za-z]+$"  //由26個(gè)英文字母組成的字符串
          "^[A-Z]+$"  //由26個(gè)英文字母的大寫組成的字符串
          "^[a-z]+$"  //由26個(gè)英文字母的小寫組成的字符串
          "^[A-Za-z0-9]+$"  //由數(shù)字和26個(gè)英文字母組成的字符串
          "^\w+$"  //由數(shù)字、26個(gè)英文字母或者下劃線組成的字符串 //開源代碼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轉(zhuǎn)字符:
          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 是用與平臺和語言無關(guān)的方式表示 XML 文檔的官方 W3C 標(biāo)準(zhǔn)。DOM 是以層次結(jié)構(gòu)組織的節(jié)點(diǎn)或信息片斷的集合。這個(gè)層次結(jié)構(gòu)允許開發(fā)人員在樹中尋找特定信息。分析該結(jié)構(gòu)通常需要加載整個(gè)文檔和構(gòu)造層次結(jié)構(gòu),然后才能做任何工作。由于它是基于信息層次的,因而 DOM 被認(rèn)為是基于樹或基于對象的。DOM 以及廣義的基于樹的處理具有幾個(gè)優(yōu)點(diǎn)。首先,由于樹在內(nèi)存中是持久的,因此可以修改它以便應(yīng)用程序能對數(shù)據(jù)和結(jié)構(gòu)作出更改。它還可以在任何時(shí)候在樹中上下導(dǎo)航,而不是像 SAX 那樣是一次性的處理。DOM 使用起來也要簡單得多。

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


          JDOM 的目的是成為 Java 特定文檔模型,它簡化與 XML 的交互并且比使用 DOM 實(shí)現(xiàn)更快。由于是第一個(gè) Java 特定模型,JDOM 一直得到大力推廣和促進(jìn)。正在考慮通過“Java 規(guī)范請求 JSR-102”將它最終用作“Java 標(biāo)準(zhǔn)擴(kuò)展”。從 2000 年初就已經(jīng)開始了 JDOM 開發(fā)。

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

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

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


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

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

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

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

            DOM4J 是一個(gè)非常非常優(yōu)秀的Java XML API,具有性能優(yōu)異、功能強(qiáng)大和極端易用使用的特點(diǎn),同時(shí)它也是一個(gè)開放源代碼的軟件。如今你可以看到越來越多的 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("運(yùn)行時(shí)間:" + (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/目錄下,怎么都不能產(chǎn)生日志到文件中,后來才發(fā)現(xiàn),原來要放到WEB-INF/classes目錄下才行。奇怪tapestry5為什么一定要這樣安排,不知有沒有什么地方是可以配置這個(gè)文件路徑的。

          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>

          最近一個(gè)新項(xiàng)目運(yùn)行這個(gè)target總是有問題,在目標(biāo)路徑?jīng)]有類文件產(chǎn)生。后來發(fā)現(xiàn)每次要將該工程的bulidpath做點(diǎn)小變化,如remove哪個(gè)路勁再添加回去,讓工程重新bulid一下,在運(yùn)行這個(gè)target就可以在目標(biāo)路徑產(chǎn)生類文件了,好奇怪,不知為什么,之前幾個(gè)項(xiàng)目都是直接運(yùn)行target就行了的。注:我用的是Eclipse開發(fā)工具。

          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 董銳 閱讀(291) | 評論 (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)編輯 收藏

          轉(zhuǎn)自: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

          下載其示例代碼后,發(fā)現(xiàn)其使用的是dwr2.0.5的版本,
          現(xiàn)若要使用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)


          ------------------------------------------------
          轉(zhuǎn)換.java文件時(shí)出錯(cuò),錯(cuò)誤竟然是“超出數(shù)組邊界”,但文件中并沒有使用任何數(shù)組,百思不得其解。

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

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

          上述錯(cuò)誤解決,頁面順利顯示。

          posted @ 2009-03-14 19:27 董銳 閱讀(553) | 評論 (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 董銳 閱讀(556) | 評論 (0)編輯 收藏



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

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

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

          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 董銳 閱讀(329) | 評論 (0)編輯 收藏

          開始加入t5c-commons-0.5.18.jar時(shí),一直不知道使用里面組件時(shí)前綴該如何寫,后來才知道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"));
              }
          這個(gè)地方定義了前綴。
          從這里可以看出,這個(gè)包下t5components和commons兩個(gè)前綴都可以用。
          <t:t5components/AjaxCheckbox></t:t5components/AjaxCheckbox>

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

          本來tapesty5有很精確的錯(cuò)誤提示,但是我的怎么就沒有了呢?
          后來在網(wǎng)上找到這樣一句話:
          tapestry5有個(gè)production-mode,默認(rèn)的為true,可以在作為產(chǎn)品發(fā)布時(shí),提供精簡的錯(cuò)誤信息,在開發(fā)時(shí),異常信息當(dāng)然是越精確越好,而且精確的異常信息也是tapestry的強(qiáng)項(xiàng),可以很準(zhǔn)確的告訴您錯(cuò)誤出在哪里,所以在開發(fā)時(shí)這個(gè)選項(xiàng)要關(guān)掉,選中運(yùn)行配置中的arguments標(biāo)簽,在vm
          arguments中添加-Dtapestry.production-mode=false

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

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



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


          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 董銳 閱讀(519) | 評論 (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 董銳 閱讀(898) | 評論 (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. 這個(gè)問題我想了好久,也盯著它看了好久,我真是不解,org.apache.tapestry.commons.components.AjaxCheckbox明明就在那,怎么會找不到呢?

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

          posted @ 2009-02-27 18:00 董銳 閱讀(152) | 評論 (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.



          如何解決?待續(xù)

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

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

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

              rational rose下載:

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

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

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

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

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


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

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

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

          主站蜘蛛池模板: 商丘市| 贺兰县| 资讯 | 板桥市| 益阳市| 阿鲁科尔沁旗| 茶陵县| 贵州省| 遵义县| 太白县| 九龙城区| 屏边| 蒲江县| 商水县| 丹阳市| 安泽县| 旬邑县| 云浮市| 榆社县| 万源市| 梅河口市| 紫阳县| 阿鲁科尔沁旗| 江达县| 右玉县| 上思县| 泸定县| 阿拉尔市| 卢龙县| 河津市| 灵寿县| 会昌县| 泗洪县| 将乐县| 靖安县| 龙井市| 喀什市| 万山特区| 沾化县| 修武县| 泰和县|