海这边

在安静处听你微弱的声音
 
 

常用链接

  • 我的随笔
  • 我的文章
  • 我的评论
  • 我的参与
  • 最新评论

留言簿(4)

  • 给我留言
  • 查看公开留言
  • 查看私人留言

随笔分类

  • Eclipse Rcp(2) (rss)
  • EJB (rss)
  • Java(7) (rss)
  • JSF(1) (rss)
  • Reg Expression(1) (rss)
  • web页面(3) (rss)
  • Work Flow(1) (rss)
  • 心情日记(4) (rss)
  • 操作系统(8) (rss)

随笔档案

  • 2011年3月 (1)
  • 2010年6月 (1)
  • 2010年3月 (1)
  • 2010年1月 (1)
  • 2009年9月 (2)
  • 2009年8月 (3)
  • 2009年5月 (2)
  • 2009年4月 (3)
  • 2009年2月 (6)
  • 2009年1月 (3)
  • 2008年12月 (2)
  • 2008年9月 (1)
  • 2008年5月 (1)
  • 2008年3月 (1)
  • 2008年1月 (1)
  • 2007年12月 (1)
  • 2007年11月 (4)
  • 2007年10月 (5)
  • 2007年9月 (1)
  • 2007年8月 (1)
  • 2007年7月 (2)
  • 2007年5月 (1)
  • 2007年4月 (1)
  • 2007年3月 (6)
  • 2007年2月 (2)
  • 2006年11月 (3)

文章档案

  • 2006年11月 (1)
  • 2006年10月 (7)
  • 2006年9月 (1)

最新随笔

  • 1. 通过Javascript代码触发事件
  • 2. linux下 mysql 备份代码
  • 3. 为Apache增加重定向功能rewrite
  • 4. Hibernate Annotation Mapping of ManyToMany
  • 5. html element
  • 6. 解决 Spring +Hibernate+DWR中出现“No converter found for 'org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer'”
  • 7. 解决 birt report 中 "Invalid javascript expression. dataSetRow["name"]"
  • 8. 用JSTL访问MAP类型
  • 9. Hibernate 延迟加载时, 用instanceof判断被延迟加载对象的类型
  • 10. 你用Spring的packagesToScan了吗?
  • 11. linux 远程自动备份MySQL数据
  • 12. Eclipse 中 将Java Project 转换为Dynamic Web Project
  • 13. 同窗的早逝
  • 14. 解决 Fiddler 在IE8中不识别 localhost 的问题
  • 15. 美好的清晨
  • 16. Java抓图软件
  • 17. JBPM 3.3+jboss 4.2.3+mysql 5 安装回忆录
  • 18. 程序界面草图设计工具Balsamiq Mockups 试用体验
  • 19. Eclipse RCP 切换到另一个视图的代码
  • 20. 感谢死亡
  • 21. 制作8G启动U盘-方法2 利用 UltroISO
  • 22. 制作8G启动U盘- 方法1 利用 DiskGenius
  • 23. 普普通通的大年初一2009
  • 24. 更新TableViewer选中行的内容
  • 25. remove empty elements from a xml string using RegExpress
  • 26. VirtualBox的网络配置与使用中的一些问题
  • 27. ubuntu8 jdk
  • 28. 又见春天
  • 29. 2008祝愿
  • 30. 解决 Qt (>= Qt 3.3 and < 4.0)
  • 31. 悲伤的一天
  • 32. Linux 学习点滴 之一 --------组与用户
  • 33. Junit越来越爽了
  • 34. 在WEB页面上创建一个彩色下拉列表框
  • 35. IceFaces 安装 auctionMonitor 示例
  • 36. Solaris 中升级jdk和简单步骤
  • 37. To Convert String to Date using JavaScript
  • 38. 使用For遍历Map
  • 39. Service Command in Linux
  • 40. 北京--看不见的城市

搜索

  •  

最新评论

  • 1. re: 你用Spring的packagesToScan了吗?
  • 评论内容较长,点击标题查看
  • --zhang0xin
  • 2. re: 你用Spring的packagesToScan了吗?
  • 把这个包com.pplus.model.*,加到context:component-scan 里去,就可以了
  • --roman
  • 3. re: Eclipse 中 将Java Project 转换为Dynamic Web Project
  • 评论内容较长,点击标题查看
  • --最代码
  • 4. re: 解决 Fiddler 在IE8中不识别 localhost 的问题[未登录]
  • 评论内容较长,点击标题查看
  • --啊啊
  • 5. re: 解决 birt report 中 "Invalid javascript expression. dataSetRow["name"]"
  • 我也遇到这个问题,可是项目中如你所说的冲突的jar包啊
  • --birt

阅读排行榜

  • 1. 你用Spring的packagesToScan了吗?(13690)
  • 2. Eclipse 中 将Java Project 转换为Dynamic Web Project(7489)
  • 3. 程序界面草图设计工具Balsamiq Mockups 试用体验(5533)
  • 4. 解决 Fiddler 在IE8中不识别 localhost 的问题(4025)
  • 5. 解决 Spring +Hibernate+DWR中出现“No converter found for 'org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer'”(3844)

评论排行榜

  • 1. 程序界面草图设计工具Balsamiq Mockups 试用体验(14)
  • 2. Eclipse 中 将Java Project 转换为Dynamic Web Project(7)
  • 3. 你用Spring的packagesToScan了吗?(6)
  • 4. 解决 Spring +Hibernate+DWR中出现“No converter found for 'org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer'”(4)
  • 5. Junit越来越爽了(4)

Powered by: 博客园
模板提供:沪江博客
BlogJava | 首页 | 发新随笔 | 发新文章 | 联系 | 聚合 | 管理

2006年11月3日

Reg Expression for a IP Address
((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
posted @ 2006-11-02 13:07 与你同飞 阅读(147) | 评论 (0) | 编辑 收藏
 

2006年10月27日

Mail Settings in Spring(Appfuse)
The mail settings are stored in mail.properties and the beans about mail sender are set in applicationContext-service.xml. They are mailEngine, mainlSender. We don't need to change mailEngine. But we must add a new property for mailSender because the default setting does not support mail authorization in many mail servers. The new property is below:
   <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${mail.host}"/>
        <property name="username" value="${mail.username}"/>
        <property name="password" value="${mail.password}"/>
        <property name="javaMailProperties">
           <props>
             <prop key="mail.smtp.auth">true</prop>
           </props>
        </property>

    </bean>
    The red lines are new. we have to add them. Otherwise the mail function in Appfuse does not work.
 

posted @ 2006-10-27 09:01 与你同飞 阅读(255) | 评论 (0) | 编辑 收藏
 

2006年10月25日

Java反射
ava的反射技术功能十分强大,整理一些资料!!


Lesson: 检测类examing class

1.Retrieving Class Objects
获取一个Class对象(metadata)

a,从对象的实例获取。
Class c = mystery.getClass();//(return Class)
b,从子类的实例获取
TextField t = new TextField();
Class c = t.getClass();
Class s = c.getSuperclass();
c,知道类名,则可以把.class加入到名字之后来获取。
Class c = java.awt.Button.class;
d,如果类名在编译时是未知的,则可以使用Class.forName()方法来获取.
Class c = Class.forName(classString);

2.Getting the Class Name
获取类名称
c.getName();

例如:
import java.lang.reflect.*;
import java.awt.*;

class SampleName {

public static void main(String[] args) {
Button b = new Button();
printName(b);
}

static void printName(Object o) {
Class c = o.getClass();
String s = c.getName();
System.out.println(s);
}
}


3.Discovering Class Modifiers
检索修改符
a.通过getModifiers()方法获取一个整型标识值。
b.通过java.reflect.Modifier对象的isPublic, isAbstract, 和 isFinal方法判断此值.

例如:
import java.lang.reflect.*;
import java.awt.*;

class SampleModifier {

public static void main(String[] args) {
String s = new String();
printModifiers(s);
}

public static void printModifiers(Object o) {
Class c = o.getClass();
int m = c.getModifiers();
if (Modifier.isPublic(m))
System.out.println("public");
if (Modifier.isAbstract(m))
System.out.println("abstract");
if (Modifier.isFinal(m))
System.out.println("final");
}
}


4.Finding Superclasses
检索父类
例如:
import java.lang.reflect.*;
import java.awt.*;

class SampleSuper {

public static void main(String[] args) {
Button b = new Button();
printSuperclasses(b);
}

static void printSuperclasses(Object o) {
Class subclass = o.getClass();
Class superclass = subclass.getSuperclass();
while (superclass != null) {
String className = superclass.getName();
System.out.println(className);
subclass = superclass;
superclass = subclass.getSuperclass();
}
}
}


5.Identifying the Interfaces Implemented by a Class
检索指定类实现的接口
例如:
import java.lang.reflect.*;
import java.io.*;

class SampleInterface {

public static void main(String[] args) {
try {
RandomAccessFile r = new RandomAccessFile("myfile", "r");
printInterfaceNames(r);
} catch (IOException e) {
System.out.println(e);
}
}

static void printInterfaceNames(Object o) {
Class c = o.getClass();
Class[] theInterfaces = c.getInterfaces();
for (int i = 0; i < theInterfaces.length; i++) {
String interfaceName = theInterfaces[i].getName();
System.out.println(interfaceName);
}
}
}
6.Examining Interfaces
判定一个类是不是接口

import java.lang.reflect.*;
import java.util.*;

class SampleCheckInterface {

public static void main(String[] args) {
Class thread = Thread.class;
Class runnable = Runnable.class;
verifyInterface(thread);
verifyInterface(runnable);
}

static void verifyInterface(Class c) {
String name = c.getName();
if (c.isInterface()) {
System.out.println(name + " is an interface.");
} else {
System.out.println(name + " is a class.");
}
}
}



如:c.isInterface()

7.Identifying Class Fields
找出指定类所有的域成员
每个数据成员可以用java.reflect.Field来封闭其名称,类型,修改符的集合。
也可以通过相应的方法获取或设置到该成员的值。

如:
import java.lang.reflect.*;
import java.awt.*;

class SampleField {

public static void main(String[] args) {
GridBagConstraints g = new GridBagConstraints();
printFieldNames(g);
}

static void printFieldNames(Object o) {
Class c = o.getClass();
Field[] publicFields = c.getFields();
for (int i = 0; i < publicFields.length; i++) {
String fieldName = publicFields[i].getName();
Class typeClass = publicFields[i].getType();
String fieldType = typeClass.getName();
System.out.println("Name: " + fieldName +
", Type: " + fieldType);
}
}
}



8.Discovering Class Constructors
检索指定类的构造函数

当创建一个类的实例时,是通过检造方法来作的,这种方法可以被重载。
每一个构造方法可以用类Constructor来描述,,包括名称,修饰符,参数类型(Class[]),和异常列表。
可以通过一个Class的getConstructors方法获取到该类的Constructor数组。
例程:
import java.lang.reflect.*;
import java.awt.*;

class SampleConstructor {

public static void main(String[] args) {
Rectangle r = new Rectangle();
showConstructors(r);
}

static void showConstructors(Object o) {
Class c = o.getClass();
Constructor[] theConstructors = c.getConstructors();
for (int i = 0; i < theConstructors.length; i++) {
System.out.print("( ");
Class[] parameterTypes =
theConstructors[i].getParameterTypes();
for (int k = 0; k < parameterTypes.length; k ++) {
String parameterString = parameterTypes[k].getName();
System.out.print(parameterString + " ");
}
System.out.println(")");
}
}
}





9.Obtaining Method Information
检索方法
可以找到隶属于一个类的所有方法,通过getMethods包含Method数组,进而得到该方法的返回类型,修饰符,方法名称,参数列表
步骤:
a.指定类的Class Object
b.getMethods()获取Method[]对象
c,遍历该数组对象

例程:

import java.lang.reflect.*;
import java.awt.*;

class SampleMethod {

public static void main(String[] args) {
Polygon p = new Polygon();
showMethods(p);
}

static void showMethods(Object o) {
Class c = o.getClass();
Method[] theMethods = c.getMethods();
for (int i = 0; i < theMethods.length; i++) {
String methodString = theMethods[i].getName();
System.out.println("Name: " + methodString);
String returnString =
theMethods[i].getReturnType().getName();
System.out.println(" Return Type: " + returnString);
Class[] parameterTypes = theMethods[i].getParameterTypes();
System.out.print(" Parameter Types:");
for (int k = 0; k < parameterTypes.length; k ++) {
String parameterString = parameterTypes[k].getName();
System.out.print(" " + parameterString);
}
System.out.println();
}
}
}
posted @ 2006-10-24 13:00 与你同飞 阅读(174) | 评论 (0) | 编辑 收藏
 

2006年10月24日

hibernate中得到具体表名,列名的方法

import org.hibernate.cfg.Configuration;

import org.hibernate.mapping.PersistentClass;

public class HibernateConfigurationHelper {

       private static Configuration hibernateConf = new Configuration();

       private static PersistentClass getPersistentClass(Class clazz) {

              synchronized (HibernateConfigurationHelper.class) {

                     PersistentClass pc = hibernateConf.getClassMapping(clazz.getName());

                     if (pc == null) {

                            hibernateConf = hibernateConf.addClass(clazz);

                            pc = hibernateConf.getClassMapping(clazz.getName());

                     }

                     return pc;

              }

       }

       public static String getTableName(Class clazz) {

              return getPersistentClass(clazz).getTable().getName();

       }

       public static String getPkColumnName(Class clazz) {

              return getPersistentClass(clazz).getTable().getPrimaryKey()

                            .getColumn(0).getName();

       }

}

posted @ 2006-10-24 09:34 与你同飞 阅读(1644) | 评论 (0) | 编辑 收藏
 
spring+hibernate无法使用lazy-loading问题的解决(ZT)

本贴转自郝感的技术中心(http://zenganiu1980.spaces.live.com/?_c11_blogpart_blogpart=blogview&_c=blogpart&partqs=cat%3dspring%2bhibernate%2bstuts%2bacegi%25e6%25a1%2586%25e6%259e%25b6%25e7%259a%2584%25e4%25bd%25bf%25e7%2594%25a8%25e7%25bb%258f%25e9%25aa%258c)

以前使用 spring 的 hibernateTemplate 时,发现都无法用 lazyloading 特性因为一旦使用,会报 session close 错误,几经查找资料,终于找到解决方法,就是在 web.xml 中加入下列 filter :

 

<filter>

       
<filter-name>hibernateFilter</filter-name>

       
<filter-class>

           org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

       
</filter-class>

    
</filter>

    
<filter-mapping>

       
<filter-name>hibernateFilter</filter-name>

       
<url-pattern>/*</url-pattern>

    
</filter-mapping>

posted @ 2006-10-24 09:20 与你同飞 阅读(1019) | 评论 (0) | 编辑 收藏
 

2006年10月18日

How to adjust the table width in Appfuse?

Appfuse is a good framework for developing web projects. But the width of tables in web pages are fixed. It looks as if a little of ugly. Fortunately, we can repair it as the following method:

  1. opens ${ProjectName}/styles/layout.css and locates at div#page. Replaces “width:781px” with “width: 95%”;
  2. opens layout-navtop-subright.css in the same folder. Locates at div#content. Replaces “width:701px”(or something else like this) with “width 95%”.
  3. Refresh the html page and you will find the tables are beautiful. Enjoy it.
posted @ 2006-10-18 09:40 与你同飞 阅读(164) | 评论 (0) | 编辑 收藏
 

2006年10月16日

add right click menu for windows explorer
    Step1. Open registry and locate to \HKEY_CLASSES_ROOT\Folder\shell;
    Step2. Add new key named "Windows Command" and add a sub key of "Command", the default  value of the new sub key is "cmd /K cd /d %L"
    Step3. That's all.
   
posted @ 2006-10-16 08:03 与你同飞 阅读(161) | 评论 (0) | 编辑 收藏
 

2006年10月6日

Appfuse 中的global.js 屏蔽了 onblur 事件
找开global.js, 找到以下函数:

function addFocusHandlers(elements) {
    for (i=0; i < elements.length; i++) {
        if (elements[i].type != "button" && elements[i].type != "submit" &&
            elements[i].type != "reset" && elements[i].type != "checkbox" && elements[i].type != "radio") {
            if (!elements[i].getAttribute('readonly') && !elements[i].getAttribute('disabled')) {
                elements[i].onfocus=function() {this.style.backgroundColor='#ffd';this.select()};
                elements[i].onmouseover=function() {this.style.backgroundColor='#ffd'};
                // elements[i].onblur=function() {this.style.backgroundColor='';} 就是这一句话使jsp(html)中的onblur事件不能触发
                elements[i].onmouseout=function() {this.style.backgroundColor='';}
            }
        }
    }
}
将其屏蔽掉即可。我还没有发现屏蔽后对系统会有什么样的影响。
posted @ 2006-10-05 12:32 与你同飞 阅读(1392) | 评论 (1) | 编辑 收藏
 

2006年9月14日

AppFuse 1.9.3 开发步骤
Step0. 假设已经安装好JRE环境变量,ANT, Tomcat也安装好.
Step 1.  安装AppFuse, 假设其安装文件夹为d:\temp\AppFuse;
Step2. 以CDM.exe 方式 进入d:\temp\AppFuse, 运行Ant new, 按提示输入新项目的名称(假设为CN2),数据库连接名称(假设为CN2),包名(假设为com.pplus)。Ant 会在d:\temp\CN2中生成新的项目;
Step3. 仍以cmd.exe 方式进入d:\temp\CN2,运行Ant setup-db, 这时会生成数据库。然后再运行Ant setup, 程序会生成我们所需要的整个项目。
Step4. 启动Eclipse,  import->Existing Projects into Workspace, 将刚才创建的新项目导入,这里新项目的名称为CN2.
Step5. 在Eclipse中Window->Show View->Ant,  打开Ant 视图,Add Buildfile 将CN2下build.xml加入,将CN2\extras\appgen\build.xml加入
Step6. (待续)...

posted @ 2006-09-13 15:05 与你同飞 阅读(252) | 评论 (0) | 编辑 收藏
 
仅列出标题  下一页