posts - 48, comments - 13, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

2009年2月27日

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

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

posted @ 2010-12-02 09:39 董锐 阅读(292) | 评论 (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 董锐 阅读(1008) | 评论 (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 董锐 阅读(445) | 评论 (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 董锐 阅读(735) | 评论 (0)编辑 收藏

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

posted @ 2010-07-14 11:20 董锐 阅读(206) | 评论 (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 董锐 阅读(13490) | 评论 (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 董锐 阅读(7394) | 评论 (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 董锐 阅读(578) | 评论 (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 董锐 阅读(1218) | 评论 (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 董锐 阅读(198) | 评论 (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 董锐 阅读(145) | 评论 (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 董锐 阅读(230) | 评论 (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 董锐 阅读(301) | 评论 (0)编辑 收藏

配置tomcat的CATALINA_PATH,记得路径后面不要带上'\'或‘;’

posted @ 2009-08-08 22:13 董锐 阅读(157) | 评论 (0)编辑 收藏

    

刚开始我将log4j.properties文件放在WEB-INF/目录下,怎么都不能产生日志到文件中,后来才发现,原来要放到WEB-INF/classes目录下才行。奇怪tapestry5为什么一定要这样安排,不知有没有什么地方是可以配置这个文件路径的。

posted @ 2009-04-28 06:26 董锐 阅读(218) | 评论 (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 董锐 阅读(924) | 评论 (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 董锐 阅读(289) | 评论 (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 董锐 阅读(849) | 评论 (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 董锐 阅读(279) | 评论 (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 董锐 阅读(551) | 评论 (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 董锐 阅读(554) | 评论 (0)编辑 收藏



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

posted @ 2009-03-08 23:27 董锐 阅读(197) | 评论 (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 董锐 阅读(326) | 评论 (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 董锐 阅读(173) | 评论 (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,果然可以了!!谢谢这位仁兄!



//////////////////////////////////////////////////////////////////////////////////
上述问题的另外解决方法:不在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 董锐 阅读(514) | 评论 (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 董锐 阅读(897) | 评论 (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
  • org.apache.tapestry5.internal.services.TransformationException
    javassist.NotFoundException: org.apache.tapestry.commons.components.AjaxCheckbox

  • 这个问题我想了好久,也盯着它看了好久,我真是不解,org.apache.tapestry.commons.components.AjaxCheckbox明明就在那,怎么会找不到呢?

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

    posted @ 2009-02-27 18:00 董锐 阅读(143) | 评论 (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 董锐 阅读(551) | 评论 (0)编辑 收藏