2009年8月10日星期一

1248375768_HvlgQr


1248375768_HvlgQr
Originally uploaded by tony_wangx
It's the first time to post weblog with flickr.

Flickr

This is a test post from flickr, a fancy photo sharing thing.

2009年5月13日星期三

Java 数字浮点型与chat之间的转化(int or float convert into char)

见这行代码:
char c=(char)(0.7+'a');
System.out.println(c);
打印的结果将是a,所以如果数字类型强行转化为char类型时,会砍掉小数点后面的小数。再转化,而不是四舍五入。

2009年5月4日星期一

用7种语言实现的数据结构与算法

有很多人在找数据结构方面的资料吧。这个可以看看,很不错。
用7种语言实现的数据结构与算法

在Ext GridPanel中设置某一列不参与分组的办法

假设你已经有一个包含分组的Grid,在其设置column的地方设置属性groupable:false。
见代码:
           {
                id: 'cost',
                header: "Cost",
                width: 20,
                sortable: false,
                groupable: false,
                dataIndex: 'cost',
                summaryType:'totalCost',
                summaryRenderer: Ext.util.Format.usMoney
            } 

    2009年5月2日星期六

    mvn无法安装jpa(jta)的解决办法 Jta1.0.1B no maven

    先去http://java.sun.com/javaee/technologies/jta/index.jsp手动下载classes文件。
    之后放到本地的一个本件家中。
    运行mvn install:install-file -Dfile=./jta-1_0_1B-classes.zip -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar
    之后再在项目中运行mvn install
    ok、

    Spring Annotation详解(AOP篇2)

    接上一篇Spring Annotation详解(AOP篇1)
    本文的相关文章有:
    Spring Annotation详解(IOC篇1)
    Spring Annotation详解(IOC篇2)
    Spring Annotation详解(IOC篇3)
    Spring Annotation详解(AOP篇1)

    上一篇介绍了基本的pointcut与advice的使用。这篇着重介绍一下除了execution之外的其他类型的pointcut。

    within:within指的是在某个范围内所有的方法执行。
    例如:
    @pointcut("within(com.xyz.project.web..*)")就是指在com.xyz.project.web包及其子包中所有的方法被执行的时候,都会触发这个pointcut。within(com.xyz.project.web.*)这样写就只是针对这个包,而不包括这个包的子包。

    this:this指的是实现了某个确定的接口的代理对象中的方法被执行。
    target:target指的是实现了某个确定的接口的代理对象中的方法被执行。
    这两种,以后再议。

    当然还有其他的类型,但是目前用到得不多。不太常见。

    2009年4月30日星期四

    Spring Annotation详解(AOP篇1)

    相关文章:Spring Annotation详解(AOP篇2)
    Spring Annotation详解(IOC篇)
    本文主要简单了解一下使用Java annotation的情况下,先介绍一下比较主流和简单的用法,Spring对AspectJ的支持。
    在ApplicationContext中加入关于AOP的命名空间,具体内容见Spring 使用AspectJ来配置AOP
    首先明确一点,用作通知(Advice)的类也应该受到ApplicationContext的管理,之后再使用AspectJ的标签来管理通知动作,见代码:
    //import ...
    @Component
    @Aspect
    public class Alert {
        @Before("execution(* get*(..))")//方法运行前通知
        public void show() {
            System.out.println("before");
        }
        @After("execution(* get*(..))")//最终通知
        public void show2() {
            System.out.println("after");    
        }
        @Pointcut("execution(* get*(..))")
        public void afterReturn(){}
        //方法返回值通知,注意这个通知需要与@Pointcut配合使用
        @AfterReturning(pointcut="afterReturn()",returning="value")
        public void returning(Object value){
            System.out.println("returning");
        }
        @AfterThrowing(pointcut="afterReturn()",throwing="ex")
        //异常通知,这个通知复用了afterReturn的pointcut。当然你也可以使用新的pointcut
        public void doRecoveryActions(Exception ex){
            //...
        }
        @Around("afterReturn()")
        //环绕通知。真正的方法实际上是joinPoint.proceed();
        public Object doSomeForAround(ProceedingJoinPoint joinPoint) throws Throwable
        {
           System.out.println("before around");
           Object retVal=joinPoint.proceed();
           System.out.println("after around");
          return retVal;
        }
    }

    这段代码的意思就是在所有以get开头的方法被调用之前和之后都会执行show和returning,show2方法,其运行顺序是show(),returning(),show2()。注意*与get*之间有一个空格。对一个方法,你可以同时使用Before Advice,Around Advice,AfterReturning Advice,After Advice,Throwing Advice。那么这些通知的顺序是什么呢?一个方法运行时,最先触发的是Around Advice,之后是Before Advice 是 AfterReturning(如果有的话),之后是After Advice,最后还要再通知Around。
    就拿上面代码这个例子说,打印的顺序是:
    before around
    before
    returning
    after
    after around

    Ruby:Timezone synchronization function(跨时区同步时间方法)

    方法是:首先取得客户端的时区,之后得到服务器的本地时区,之后取得两个时区的差值,计算出相应的时间。
    输入:服务器时间
    输出:相应的客户端对应的时间
    上代码:
      #时间同步方法
      #clint_timezone:client timezone
      def formate_date_to_client_time_zone(clint_timezone,time)
        diff=(clint_timezone-get_server_time_zone)
        unless(clint_timezone.nil?)
          time=time+diff*3600
        end
        return time
      end
      #获得本地时区
      #return the server timezone
      def get_server_time_zone
        return Time.now.gmtoff/3600
      end

    2009年4月29日星期三

    Ruby:string to date Or date to string

    Ruby:string to date Or date to string
    #string to date:
    str="2009-02-02"
    date=Date.strptime(str,"%Y-%m-%d")
    #date to string:
    date=Date.new(2009,2,2)
    str=date.strftime("%Y-%m-%d")

    2009年4月28日星期二

    超炫的flex特效,UI做到这份上,应该说无敌了。

    Efflex 是一组由 Stephen Downs (aka “Tink”)开发的 Flex特效。
    留个纪念,慢慢看
    这里是demo

    正则表达式验证邮箱地址

    定义以下模式为有效的:
    1. john@hotmail.com
    2. john.doe@somewhere.com
    3. John Doe<john.doe@somewhere.com>
    javascript的正则表达式为
    var reEmail=/^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;

    2009年4月27日星期一

    Flex:浅谈Flex事件机制

          一直对RIA技术非常感兴趣,研究了一下Flex的事件机制,发现Flex的事件机制和Javascript很像,只不过更加严格。在Flex的事件机制中有一个比较重要的概念dispatchEvent,基本原理就是事件所在的容器类初始化的时候注册其事件监听函数。如果需要自己定义Event类型,需要将事件分发到事件队列中,也就是dispatchEvent。也就是你要手动找到自定义的事件的前一个事件,在这个结束的时候调用dispatchEvent(event),这个event就是你自定一个事件,这个事件(一个类)一定要继承flash.events.Event
    给个例子:
    自定义的事件类:
    public class AddressFormEvent extends Event

    {
    public static const SUBMIT:String = "submit";
    private var _data:AddressVO;
    public function AddressFormEvent (eventName:String)
    {
    super (eventName);
    }
    public function set data (value:AddressVO):void
    {
    _data = value;
    }
    public function get data ():AddressVO
    {
    return _data;
    }
    }
    在上一个事件结束的时候发布这个事件,下面这段代码就是找到上一个事件:
    public class AddressFormClass extends Form

    {
    public var submitButton:Button;
    public var nameInput:TextInput;
    public var street:TextInput;
    public var city:TextInput;
    public var state:TextInput;
    public var country:CountryComboBox;
    public var otherInput:TextInput;
    public var otherText:Text;
    public function AddressFormClass():void
    {
    addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);
    }
    private function creationCompleteHandler(event:FlexEvent):void
    {
    submitButton.addEventListener(MouseEvent.CLICK,submitHandler);
    }
    private function submitHandler(event:MouseEvent):void //这个就是上一个事件的监听函数
    {
    // Gather the data for this form
    var addressVO:AddressVO = new AddressVO();
    addressVO.name = nameInput.text;
    addressVO.street = street.text;
    addressVO.city = city.text;
    addressVO.state = state.text;
    addressVO.country = country.selectedItem as String;
    // 下面就是创建这个事件自定义事件,注意类型就是我们刚刚建的那个事件类。
    var submitEvent:AddressFormEvent = new AddressFormEvent(AddressFormEvent.SUBMIT);
    submitEvent.data = addressVO;
    // Dispatch an event to signal that the form has been submitted
    dispatchEvent(submitEvent); //这就是发布这个时间
    }
    }

    2009年4月26日星期日

    Spring 使用AspectJ来配置AOP

    在Application_context中引入名称空间,例子:<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:lang="http://www.springframework.org/schema/lang"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
         http://www.springframework.org/schema/lang
         http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-2.5.xsd">
      <context:component-scan base-package="bean"/>
      <aop:aspectj-autoproxy/>
    </beans>

    2009年4月24日星期五

    在ExtJs应用中快速为页面元素添加tooltip

    ExtJs是通过Ext.ToolTip和Ext.QuickTips两个组件来实现浮动提示功能的。

    QuickTips代码示例:只需要加入Ext.QuickTips.init(); 就可以在html页面中使用。html页面 可以通过:
    <input type="button" value="OK" ext:qtitle="Test" ext:qtip="Test Content!">

    2009年4月23日星期四

    Javascript方式打开一个浏览器

    var newWindow=window.open(url,'txtPopup','height=768,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=1024,resizable=0');
    newWindow.focus();

    javascript 刷新页面的方式:
    1. history.go(0)
    2. location.reload()
    3. location=location
    4. location.assign(location)
    5. document.execCommand('Refresh')
    6. window.navigate(location)
    7. location.replace(location)
    8. document.URL=location.href

    JRuby On Spring在spring框架中使用Jruby

    昨天尝试在Spring中使用脚本语言,比如jruby,发现非常不方便,最主要的一点就是ruby class必须继承某一个java的接口,而其他bean调用时也是调用这个接口类型的对象。jruby的动态性基本丧失了。唉!

    JRuby的性能优化(update)

    JRuby wiki上列出了性能优化的四条建议:
    1、调优编译器,JRuby早就弃暗投明跟随XRuby走上了编译这条牛B的道路,将Ruby Script编译成字节码,因此这个环节是断断不能忽略的。
    两种编译方式:
    AOT模式:直接生成class文件,脱了Ruby这层皮,咱就是人见人“爱”的java了。
    JIT模式:充分利用成熟的jit技术,咱不全脱,朦胧美才是真的美。默认从0.9.9版本开始就是开启的,关闭的话(要我说还不如全脱)
    jruby -J-Djruby.jit.enabled=false
    2、关闭ObjectSpace
    ObjectSpace是Ruby用来操作所有运行时对象的模块,这个功能相当牛x。这个的实现在c ruby里是比较容易的,但是对于JRuby代价就比较昂贵了,其实就大部分情况下你基本用不到这个东东,那么最好就是关闭它,JRuby提供了
    jruby -J-Djruby.objectspace.enabled=false选项来关闭它。
    3、开启线程池
    我们知道,在c ruby中的线程是绿色的轻量级线程,因此运行时就动不动开个百来十个“线程”跑一跑充下款爷;然而在JRuby中,线程的实现那可是实打实的本地线程(也就是Ruby线程与java线程一比一),你这么动不动上百个线程那不慢才怪了。因此JRuby提供了线程池选项,运行时尽可能地满足你的要求开线程,但是当短命的Ruby线程重复创建的时候,这些线程将被复用,这在大多数情况下能提高性能表现,特别是在每次调用都启动一个线程的情况下。不过具体效果还是要测试的实际数据说话。
    jruby -J-Djruby.thread.pooling=true
    4、使用Java "server"模式虚拟机,地球淫都知道
    jruby -J-server myscript.rb
    5、尽量使用最新的jdk,在我的测试中,jdk6跑jruby是效率最高的。

    2009年4月22日星期三

    用ruby写的一个网络爬虫程序

    前几天写的一个ruby爬虫,专抓指定网站的图片
    require 'net/http'
    require "monitor"
    def query_url(url)
      return Net::HTTP.get(URI.parse(url));
    end
    def save_url(url,dir,filename)
      filename = url[url.rindex('/')+1, url.length-1] if filename == nil || filename.empty?
      require 'open-uri'
      Dir.mkdir("#{dir}") if dir != nil && !dir.empty? && !FileTest.exist?(dir)
      open(url) do |fin|
          File.new("#{dir}#{filename}","wb").close
          open("#{dir}#{filename}","wb") do |fout|
            while buf = fin.read(1024) do
              fout.write buf
              STDOUT.flush
            end
          end
      end
    end
    def download_page(content)
      content.scan(/<[Ii][Mm][Gg].* src="\S+[^ni]."/) {|match|
        match.scan(/http:\/\/\S+"/){|img|
          img=img.gsub(/"/,'')
          puts "img:"+img
          begin
            save_url(img,"E:\\TET\\",nil)
          rescue =>e
            puts e
          ensure
            next
          end
        }
      }
    end
    begin
      start_url = 'http://se.1ssdd.com/'
      print "开始搜索#{start_url}\n"
      content = query_url(start_url)
      next_host = "http://se.1ssdd.com/"
      threads=[]
      i=1
      content.scan(/<a href="\/(.*?\.html)"/) {|match|
        if  !match.nil? && match.size>0
          threads<<Thread.new(match) do |urls|
            urls.each{|url|
              next_url =next_host+url
              puts next_url+"::"+i.to_s
              page=query_url(next_url)
              download_page(page)
            }
          end
        end
      }
      threads.each{|thr| thr.join}
      download_page(content)
      p "over"
    end

    Ruby 递归删除文件目录

    递归删除文件目录:
    require 'pathname'
    dir=Pathname.new("/home/poole/")
    dir.rmtree

    #or

    require 'fileutils'
    FileUtils.rm_r("/home/poole")

    Spring Annotation详解(IOC篇3)

    本文接上一篇Spring Annotation详解(IOC篇2)
    除了之前提到的@Autowired,@Component,@Sevice,@Controller,@Repository,@Scope,@Qualifier之外还有其他的一些用于IOC的Annotation
    @Resource
        @Resource
        public void setOwner(Member owner) {
            this.owner = owner;
        }
    或者
        @Resource(name="member")
        public void setOwner(Member owner) {
            this.owner = owner;
        }

    其中特别之处在于@Resource如果加载属性或者setter之上,则按照属性名或者根据setter名称得到bean名称查找,如果找不到则按照类型查找。如果给@Resource加了name属性,则相当于按照这个名称查找,这种方式查找的优先级最高。

    Spring Annotation详解(IOC篇2)

    本文接上一篇Spring Annotation详解(IOC篇)
    在bean中我们已经看到了最基本的使用Java annotation的方式了,但是Spring对于Annotation还存在一些问题,比如:@Autowired同样可以应用于Collection中,比如List中。但是如果在List的属性中加上这个Annotation,那么通过容器初始化的bean会自动往List中存放一个通过@Autowired自动查找出来的对象,这么做我也很难说它不对,但是还是感觉怪怪的。希望大家注意。
    另外谈一下自动检测组件名称的方式(针对于@Component,@Service,@Controller,@Repository):如果给组件命名了,则按照这个名称注册到BeanFactory中,如果没有命名,则把小写开头的类名注册为组件名称。@Component("project")
    public class MyProject {
    //......
    }

    如果是@Component,那么在ApplicationContext或者BeanFactory中注册的Bean名称是"myProject",如果是@Component("project"),则注册的Bean名称是"project"。

    2009年4月21日星期二

    Spring Annotation详解(IOC篇)

    本文的相关文章有:
    Spring Annotation详解(IOC篇2)
    Spring Annotation详解(IOC篇3)
    Spring Annotation详解(AOP篇1)
    首先在application_context的xml配置文件中加入<context:component-scan base-package="org.bean"/>,而且保证xml的schema中包括context名称空间。
    @Component
    //例如
    @Component("member")
    public class Member {
       private String id;
       }

    这个Annotation主要用来定义bean。
    @Service,@Controller,@Repository
    这3个目前与@component同意,以后版本会细化。
    @Autowired
    //例如
    @Component("member")
    public class Member {
       private String id;
       @Autowired
       private Project project;
       }

    这个Annotation主要用来自动查找context,并且关联其中的bean。
    @Qualifier@Component("member")
    public class Member {
       private String id;
       private String name;
       @Autowired
       @Qualifier("project")
       private Project project;
       }

    这个Annotation主要用来自动关联时的微调
    @Scope    @Scope("singleton")
        @Component("member")
        public class Member {
            private String id;
            private String name;
            @Autowired
            @Qualifier("project")
            private Project project;
            }

    这个Annotation用来指定bean作用域与生成状态,默认为singleton,其他还有prototype(多个实例),request,session,global session,这3个是用在基于Spring ApplicationContext的Web项目。

    不允许选择文字的css(-moz-user-select,onselectstart)

    <div unselectable="on" onselectstart="return false;" style="-moz-user-select:none;" >你选不了我,unselectable为IE准备 , onselectstart为Chrome、Safari准备    -moz-user-select是FF的 </div>

    试试:点点下边这句
    你选不了我,unselectable为IE准备 , onselectstart为Chrome、Safari准备 -moz-user-select是FF的

    2009年4月20日星期一

    Ruby on Rails ActiveRecord中Has_many的参数说明

    :class_name
    Specify the class name of the association. Use it only if that name can‘t be inferred from the association name. So has_many :products will by default be linked to the Product class, but if the real class name is SpecialProduct, you‘ll have to specify it with this option.
    :conditions
    Specify the conditions that the associated objects must meet in order to be included as a WHERE SQL fragment, such as price > 5 AND name LIKE ‘B%’. Record creations from the association are scoped if a hash is used. has_many :posts, :conditions => {:published => true} will create published posts with @blog.posts.create or @blog.posts.build.
    :order
    Specify the order in which the associated objects are returned as an ORDER BY SQL fragment, such as last_name, first_name DESC.
    :foreign_key
    Specify the foreign key used for the association. By default this is guessed to be the name of this class in lower-case and "_id" suffixed. So a Person class that makes a has_many association will use "person_id" as the default :foreign_key.
    :primary_key
    此项用来设置关联主键,默认为ID。
    :dependent
    如果此项设置为:destroy那么当删除此对象时,会关联删除many端的所有对象,并且会在删除之前调用destroy方法。如果设置为:delete_all这同样是关联删除,但是不会调用destroy方法。如果设置为:nullify,则会将所有的外键设置为null而不删除。
    *注意:* 当启用 :through 选项时,:dependent选项将被忽略.
    :finder_sql
    Specify a complete SQL statement to fetch the association. This is a good way to go for complex associations that depend on multiple tables. Note: When this option is used, find_in_collection is not added.
    :counter_sql
    Specify a complete SQL statement to fetch the size of the association. If :finder_sql is specified but not :counter_sql, :counter_sql will be generated by replacing SELECT … FROM with SELECT COUNT(*) FROM.
    :extend
    Specify a named module for extending the proxy. See "Association extensions".
    :include
    Specify second-order associations that should be eager loaded when the collection is loaded.
    :group
    An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause.
    :having
    Combined with +:group+ this can be used to filter the records that a GROUP BY returns. Uses the HAVING SQL-clause.
    :limit
    An integer determining the limit on the number of rows that should be returned.
    :offset
    An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows.
    :select
    By default, this is * as in SELECT * FROM, but can be changed if you, for example, want to do a join but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error.
    :as
    Specifies a polymorphic interface (See belongs_to).
    :through
    Specifies a Join Model through which to perform the query. Options for :class_name and :foreign_key are ignored, as the association uses the source reflection. You can only use a :through query through a belongs_to or has_many association on the join model.
    :source
    Specifies the source association name used by has_many :through queries. Only use it if the name cannot be inferred from the association. has_many :subscribers, :through => :subscriptions will look for either :subscribers or :subscriber on Subscription, unless a :source is given.
    :source_type
    Specifies type of the source association used by has_many :through queries where the source association is a polymorphic belongs_to.
    :uniq
    If true, duplicates will be omitted from the collection. Useful in conjunction with :through.
    :readonly
    If true, all the associated objects are readonly through the association.
    :validate
    If false, don‘t validate the associated objects when saving the parent object. true by default.
    :autosave
    If true, always save any loaded members and destroy members marked for destruction, when saving the parent object. Off by default.

    Spring IoC application context sample

    基于XML的context
    <bean id="project" class="bean.Project">
     <property name="owner">
      <bean class="bean.Member">
       <property name="project">
        <ref bean="project"/>
       </property>
      </bean>
     </property>
    </bean>

    使用p名称空间,简化如下
    <bean id="project" class="bean.Project" p:owner-ref="member"/>
    <bean id="member" class="bean.Member" p:project-ref="project"/>

    在bean的属性中"depends-on"属性不仅指定依赖加载的bean,而且也是销毁时的依赖顺序(该依赖只针对singletonbean)。

    Ruby on Rails单元测试(Unit Test)的数据准备

    一般来说,在运行Rails单元测试(Unit Test)之前,都要进行rake db:test:prepare
    如果你想一次性把所有DB table都建立好,也可以用这个:rake environment RAILS_ENV=test db:migrate
    虽然这样做不标准,但是比较快捷,前提是你的migrate脚本中没有会导致出问题的脏数据。

    Ruby on Rails单元测试(Unit Test)


    (MySQL环境)
    #首先建立测试数据库
    mysqladmin -u root create db_test
    #建立数据库结构
    rake db:test:prepare
    #运行测试
    ruby test/unit/product_test.rb

    2009年4月19日星期日

    MYSQL 外键定义

    MYSQL 外键定义
    建立外键的前提: 本表的列必须与外键类型相同(外键必须是外表主键)。
    外键作用: 使两张表形成关联,外键只能引用外表中的列的值!
    指定主键关键字: foreign key(列名)
    引用外键关键字: references <外键表名>(外键列名)
    事件触发限制: on delete和on update ,
    可设参数cascade(跟随外键改动),
    restrict(限制外表中的外键改动),
    set Null(设空值),
    set Default(设默认值),
    [默认]no action
    例如: outTable表 主键 id 类型 int
    创建含有外键的表:
    create table temp(
    id int,
    name char(20),
    foreign key(id) references outTable(id) on delete cascade on update cascade
    );

    说明:把id列 设为外键 参照外表outTable的id列 当外键的值删除 本表中对应的列筛除 当外键的值改变 本表中对应的列值改变。

    Spring包结构以及各个包之间引用关系说明

    Spring包结构以及各个包之间引用关系说明
    Spring 包结构说明:
    spring.jar
    包含有完整发布的单个jar包。他包含有除spring-mock.jar之外的所有jar。原因是,spring-mock.jar只有在开发环境中才会用到,而且仅仅是作为一个辅助测试类存在。除了spring.jar,spring还包括13个独立的jar文件,他们各自包含这spring各自的组件。所以,如果你可以明确知道使用spring的哪些资源文件时,就没必要去直接引入spring.jar,但有时候spring.jar的引入也是最偷懒和最直接的方式。
    spring-core.jar
    这个jar包含spring框架基本的核心工具类,spring其他组件都要使用到这个包里的类。是其他组件的基本核心。
    spring-beans.jar
    这个jar是所有应用都要用到的,他包含访问配置文件,创建和管理bean以及进行Inversion of Control / Dependency Injection(IoC/DI)操作相关的所有类如果应用只需基本的IoC/DI支持,引入spring-core.jar和spring-beans.jar就已经足够了。
    spring-aop.jar
    包含一些使用AOP特性时需要用到的一些类。在使用spring 的AOP特性如Declarative Transaction Management(事务管理)就需要用到这个jar文件。
    spring-context.jar
    这个jar文件为spring提供了大量扩展。可以找到使用Spring ApplicationContext特性时所需的全部类。JNDI所需的全部类,用来跟模板引擎集成(Velocity,FreeMarker,JasperReports)的类,以及校验相关类。
    spring-dao.jar
    包含Spring DAO、Spring Transaction进行数据访问的所有类,为了使用声明性事务支持还需要在自己的应用里包含spring-aop.jar
    spring-hibernate.jar
    是对Hibernate支持的所有类。
    spring-orm.jar
    该jar对spring DAO特性集合进行了扩展,使其支持iBATIS、JDOOJB、TopLink,由于spring将hibernate独立成包了,因此在这里没有在支持hibernate。这个文件里大部分的类都依赖spring-dao.jar中的类。
    spring-remoting.jar
    这个包提供对EJB、JMS以及远程调用(RMIHessianBurlapHttp Invoker JAX-RPC)相关的类
    spring-support.jar
    该组件提供对Cache(ehcache)、JCA、JMX,邮件服务(Java Mail、COS Mail),计划任务Scheduling(Timer、Quartz)支持的类
    spring-web.jar
    如果web开发中开发,而且用到用到spring框架,那就应该引入这个包,该组件包括WebApplicationContext特性的类、struts与JSF集成类、文件上传的支持类、Filter类和大量工具辅助类。
    spring-webmvc.jar

    该组件包含Spring MVC框架相关的所有类,包含国际化、标签、Theme、视图展现的FreeMarker、JasperReports、Tiles、Velocity、XSLT相关类。如果使用了独立的MVC框架则该组件不再需要。
    spring-mock.jar

    这个文件中包含Spring一整套mock类来辅助应用的测试。spring测试套件使用了大量的mock类,这样测试就更加简单了。由于可以对HttpServletRequest和HttpServletResponse进行模拟,使得对web进行单元测试更加方便。

    包间引用关系:
    Spring中各个包引入之前都需要保证引入 commons-logging.jar

    spring-core.jar需 commons-collections.jar,spring-core.jar 是以下其他各个组件的基础。

    spring-beans.jar需 spring-core.jar/cglib-nodep-2.1_3.jar

    spring-aop.jar需 spring-core.jar/spring-beans.jar/cglib-nodep-2.1_3.jar/aopalliance.jar

    spring-context.jar 需spring-core.jar/spring-beans.jar/spring-aop.jar/commons-collections.jar/aopalliance.jar

    spring-dao.jar需 spring-core.jar/spring-beans.jar/spring-aop.jar/spring-context.jar

    spring-jdbc.jar需 spring-core.jar/spring-beans.jar/spring-dao.jar

    spring-web.jar需 spring-core.jar/spring-beans.jar/spring-context.jar

    spring-webmvc.jar需 spring-core.jar/spring-beans.jar/spring-context.jar/spring-web.jar

    spring-hibernate.jar 需 spring-core.jar/spring-beans.jar/spring-aop.jar/spring-dao.jar/spring-jdbc.jar/spring-orm.jar/spring-web.jar/spring-webmvc.jar

    spring-orm.jar 需 spring-core.jar/spring-beans.jar/spring-aop.jar/spring-dao.jar/spring-jdbc.jar/spring-web.jar/spring-webmvc.jar

    spring-remoting.jar 需 spring-core.jar/spring-beans.jar/spring-aop.jar/spring-dao.jar/spring-context.jar/spring-web.jar/spring-webmvc.jar

    spring-support.jar 需 spring-core.jar/spring-beans.jar/spring-aop.jar/spring-dao.jar/spring-context.jar/spring-jdbc.jar

    spring-mock.jar 需 spring-core.jar/spring-beans.jar/spring-dao.jar/spring-context.jar/spring-jdbc.jar

    Spring Framework's Building Blocks

    Spring Framework's Building Blocks
         Spring is an application framework wand is divided into several modules or components. Each module provides a specified set of functionality and works more or less independently of the others.Needless to say,these modules can be leveraged to build scalable yet flexible enterprise Java applications.This system is very flexible,because developers can choose to use only the module that is most appropriate in the context of a problem.For example,a developer can just use the Spring DAO module and build the rest of the application with non-Spring components.Moreover,Spring provides integration points ot work with other frameworks and APIs.If you think Spring is unsuitable in aparticular scenario,you can use alternatives.In case the development team is more proficient in Struts,for example,it can be used instead of Spring MVC while the rest of the application uses Spring components and features such as JDBC and transactions.In the two scenarios described here,the developers need not deploy the entire Spring Framework.They will require only the relevant module along with the pring IOC container and the Struts libraries.

    2009年4月17日星期五

    Why is Spring So Important?

    Why is Spring So Important?
         Java EE 平台主要希望解决复杂的分布式的应用程序的开发,在中间件厂商与开源社区的大力支持下,传统的JavaEE架构在标准的low-level 中间件服务平台之上,通过一系列的APIs(EJB,JTA,JMS)也可以成功的开发。由于这些陈旧的JavaEE项目首要关注点都在标准化服务上,而忽略了开发的简单性原则。所以基于JavaEE平台的项目往往投入巨大。
        Java EE平台目标是用来开发基于模块的应用。而模块是指一个单独的程序,一段可以在复杂项目中简单重用的代码。例如:一个order模块包含一个用来持久化的entity bean,一个用来处理业务流程的的session bean,理论上,这样的模块在很大程度上是可以重用的,但是,现实中,这些模块往往使用率不高。Java EE 程序的复杂性主要表现在编写model的时候,开发java EE model 往往需要写很多不必要的重复的代码和测试。这其中至少包括一段典型的在JBDI tree上查阅EJB对象的代码,获得一个数据库链接,拼装并执行数据库查询,并且最终释放数据库资源。首先,这样的程序极大地破坏了OO的封装原则,而且无谓的浪费了大量的程序员的人力。EJBs 的设计初衷是解决分布性事物的,虽然大部分的JavaEE项目包含数据库操作,进而需要一些事物操作,但是这些项目不需要分布性事物。但是一旦使用了EJBs,项目中就引入了大量的用语处理分布性事务的代码。而且这个本来不需要分布性的项目也就成了一个分布性应用,由于有分布性的特性(虽然没用到),所以也对部署和硬件提出了更高的要求。而且由于基于EJBs的程序对JavaEE容器有比较大的依赖,所以Unit Test也变得很困难。所以TDD基本变得不可能。
        由于JavaEE开发的复杂性。Java社区提出了许多新的框架来代替传统的JavaEE架构。其中Struts是一个基于servlet API的MVC实现。Hibernate解决了entity bean的痛苦旅程,它提供了一个基于POJOs的持久化框架,由于POJO不是一个分部式的对象,所以和entity bean相比,它有着更加出色的性能。而且Hibernate不依赖任何容器,所以单元测试也就变得很容易了。
        不同于Struts与Hibernate,Spring Framework 并不是为了提供单独某一层的框架。他实际上提供了一种跨曾的框架支持,在分层的应用体系中,它帮助各层的独特框架更好的交互,而有不用意识到其他层的存在,由于Spring提供一个简单的基于POJOs,并且脱离JavaEE容器的开发环境,所以单元测试也就更加容易了。

    Ext.TabPanel遇到的问题与解决方法

    今天在Ext.form.FormPanel中嵌套TabPanel时,发现了这样一个问题:
    创建了一个FormPanel,在这个Panel中需要以Tab的方式展现数据,每个TabPanel中包含一个FormPanel的字段。但是我发现在每次FormPaneel中的数据load完成之后,只有处于Active状态的Tab中的数据存在,而Active其他Tab后,数据都看不见,所以我怀疑是BasicForm装载数据的时候,这些处于非active状态的panel并没有创建出来。
    解决办法:
    在FormPanel中的Form装载完数据后,把这些出具备份到这个BasicForm中的一个属性中,比如result_data。之后在TabPanel的这些Field渲染的时候,判断result_data是否存在,如果存在,则把对应的字段值填进去。
    示例代码:

    //监听basicForm中的数据加载完成
    new Ext.FormPanel({
    listeners:{
    actioncomplete:function(form,action){
    if(action.type=="load"){
    form.result_data=action.result.data
    }
    }
    }
    ...
    ...
    //formPanel中嵌套的tabPanel
    {
    xtype:'tabpanel',
    activeTab: 0,
    items : [{
    title : track_window.column.text_what_has_been_done,
    height : 180,
    layout:'fit',
    items:{//tabPanel中所包含的Form的字段
    xtype : 'htmleditor',
    name : 'progress_log_desc[has_done]',
    autoScroll: true,
    listeners:{//监听此字段的render事件
    render:function(he){
    var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
    if(data!=null&&data!=undefined){
    he.setValue(data["progress_log_desc[has_done]"])
    }
    }
    }
    }
    }, {
    title : track_window.column.text_what_impedes,
    height : 180,
    layout:'fit',
    items:{
    xtype : 'htmleditor',
    name : 'progress_log_desc[impedes]',
    autoScroll: true,
    listeners:{
    render:function(he){
    var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
    if(data!=null&&data!=undefined){
    he.setValue(data["progress_log_desc[impedes]"])
    }
    }
    }
    }
    }, {
    title : track_window.column.text_what_next,
    height : 180,
    layout:'fit',
    items:{
    xtype : 'htmleditor',
    name : 'progress_log_desc[the_next]',
    autoScroll: true,
    listeners:{
    render:function(he){
    var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
    if(data!=null&&data!=undefined){
    he.setValue(data["progress_log_desc[the_next]"])
    }
    }
    }
    }
    }, {
    title : track_window.column.text_other_comments,
    height : 180,
    layout:'fit',
    items:{
    xtype : 'htmleditor',
    name : 'progress_log_desc[other_comments]',
    autoScroll: true,
    listeners:{
    render:function(he){
    var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
    if(data!=null&&data!=undefined){
    he.setValue(data["progress_log_desc[other_comments]"])
    }
    }
    }
    }
    }]
    }

    2009年4月16日星期四

    SpringSide3 个人理解之DAO&Service篇

    今天看了SpringSide3的例子,并且仔细看了源码。发现其实SpringSide3与我想的差异比较大,SpringSide3其实并不是一个code genaretor,而是一种架构风格,他是倡导的一种构建应用的风格。在充分利用已有框架和Java特性的基础之上快速建立应用的风格。废话不多说,列举一些例子,这些都是从demo中得到的感触。
    拒绝无谓的过多的不必要的繁琐的没有意义的Interface。不否认有些时候需要接口,特别是提供API的时候,可是在JAVA语言中,接口更多的是概念级的东西。它固然有非常多的有点,可是在项目中无谓的无条件的遵循接口->实现的设计准则,有点本末倒置的感觉。其实很多时候用父类->子类的模式可能更加方便一点。补充一点:关于接口和继承的关系:“接口是调用方要求的结果,而继承则是实现方思考的产物。”
    Sping中有HibernateTemplate。但是这个东西也是比较被人诟病的,主要是它用起来是很简单但是功能太简单,并不能完全取代DAO层。封装SpringSide扩展功能的Hibernat范型基类HibernateDao也比较简单,可是由于是基于原生HibernateAPI,所以利于扩展,实际上一般我们在项目中也是这么做的。而DefaultEntityManager类给人的感觉很像RoR中model的基类,基本实现了entity的管理同时子类又可以自由扩展。总的来说,在这块其实倒也都是常用的方式和技巧,只不过SS3提供了更加规范的实现方式。利于后来人的维护。总的来时封装DAO与Service层基本可以统一了。由于使用了JAVA的注释特性,真的达到了几乎0配置。否则Hibernate和Spring的配置文件,即便使用XDoclet,也需要很费劲的写很多配置及部署文件。

    windows命令行大全


    命令名
    ASSOC 显示或修改文件扩展名关联。
    AT 计划在计算机上运行的命令和程序。
    ATTRIB 显示或更改文件属性。
    BREAK 设置或清除扩展式 CTRL+C 检查。
    CACLS 显示或修改文件的访问控制列表(ACLs)。
    CALL 从另一个批处理程序调用这一个。
    CD 显示当前目录的名称或将其更改。
    CHCP 显示或设置活动代码页数。
    CHDIR 显示当前目录的名称或将其更改。
    CHKDSK 检查磁盘并显示状态报告。
    CHKNTFS 显示或修改启动时间磁盘检查。
    CLS 清除屏幕。
    CMD 打开另一个 Windows 命令解释程序窗口。
    COLOR 设置默认控制台前景和背景颜色。
    COMP 比较两个或两套文件的内容。
    COMPACT 显示或更改 NTFS 分区上文件的压缩。
    CONVERT 将 FAT 卷转换成 NTFS。您不能转换
    当前驱动器。
    COPY 将至少一个文件复制到另一个位置。
    DATE 显示或设置日期。
    DEL 删除至少一个文件。
    DIR 显示一个目录中的文件和子目录。
    DISKCOMP 比较两个软盘的内容。
    DISKCOPY 将一个软盘的内容复制到另一个软盘。
    DOSKEY 编辑命令行、调用 Windows 命令并创建宏。
    ECHO 显示消息,或将命令回显打开或关上。
    ENDLOCAL 结束批文件中环境更改的本地化。
    ERASE 删除至少一个文件。
    EXIT 退出 CMD.EXE 程序(命令解释程序)。
    FC 比较两个或两套文件,并显示
    不同处。
    FIND 在文件中搜索文字字符串。
    FINDSTR 在文件中搜索字符串。
    FOR 为一套文件中的每个文件运行一个指定的命令。
    FORMAT 格式化磁盘,以便跟 Windows 使用。
    FTYPE 显示或修改用于文件扩展名关联的文件类型。
    GOTO 将 Windows 命令解释程序指向批处理程序
    中某个标明的行。
    GRAFTABL 启用 Windows 来以图像模式显示
    扩展字符集。
    HELP 提供 Windows 命令的帮助信息。
    IF 执行批处理程序中的条件性处理。
    LABEL 创建、更改或删除磁盘的卷标。
    MD 创建目录。
    MKDIR 创建目录。
    MODE 配置系统设备。
    MORE 一次显示一个结果屏幕。
    MOVE 将文件从一个目录移到另一个目录。
    PATH 显示或设置可执行文件的搜索路径。
    PAUSE 暂停批文件的处理并显示消息。
    POPD 还原 PUSHD 保存的当前目录的上一个值。
    PRINT 打印文本文件。
    PROMPT 更改 Windows 命令提示符。
    PUSHD 保存当前目录,然后对其进行更改。
    RD 删除目录。
    RECOVER 从有问题的磁盘恢复可读信息。
    REM 记录批文件或 CONFIG.SYS 中的注释。
    REN 重命名文件。
    RENAME 重命名文件。
    REPLACE 替换文件。
    RMDIR 删除目录。
    SET 显示、设置或删除 Windows 环境变量。
    SETLOCAL 开始批文件中环境更改的本地化。
    SHIFT 更换批文件中可替换参数的位置。
    SORT 对输入进行分类。
    START 启动另一个窗口来运行指定的程序或命令。
    SUBST 将路径跟一个驱动器号关联。
    TIME 显示或设置系统时间。
    TITLE 设置 CMD.EXE 会话的窗口标题。
    TREE 以图形模式显示驱动器或路径的目录结构。
    TYPE 显示文本文件的内容。
    VER 显示 Windows 版本。
    VERIFY 告诉 Windows 是否验证文件是否已正确
    写入磁盘。
    VOL 显示磁盘卷标和序列号。
    XCOPY 复制文件和目录树。


    appwiz.cpl------------添加删除程序

    control userpasswords2--------用户帐户设置

    cleanmgr-------垃圾整理

    CMD--------------命令提示符可以当作是 Windows 的一个附件,Ping,Convert 这些不能在图形环境下 使用的功能要借助它来完成。

    cmd------jview察看Java虚拟机版本。


    command.com------调用的则是系统内置的 NTVDM,一个 DOS虚拟机。它完全是一个类似 Virtual PC 的 虚拟环境,和系统本身联系不大。当我们在命令提示符下运行 DOS 程序时,实际上也 是自动转移到 NTVDM虚拟机下,和 CMD 本身没什么关系。


    calc-----------启动计算器

    chkdsk.exe-----Chkdsk磁盘检查

    compmgmt.msc---计算机管理

    conf-----------启动 netmeeting

    control userpasswords2-----User Account 权限设置

    devmgmt.msc--- 设备管理器

    diskmgmt.msc---磁盘管理实用程序

    dfrg.msc-------磁盘碎片整理程序

    drwtsn32------ 系统医生

    dvdplay--------启动Media Player

    dxdiag-----------DirectX Diagnostic Tool

    gpedit.msc-------组策略编辑器

    gpupdate /target:computer /force 强制刷新组策略

    eventvwr.exe-----事件查看器

    explorer-------打开资源管理器

    logoff---------注销命令

    lusrmgr.msc----本机用户和组

    msinfo32---------系统信息

    msconfig---------系统配置实用程序

    net start (servicename)----启动该服务

    net stop (servicename)-----停止该服务

    notepad--------打开记事本

    nusrmgr.cpl-------同control userpasswords,打开用户帐户控制面板

    Nslookup-------IP地址侦测器

    oobe/msoobe /a----检查XP是否激活

    perfmon.msc----计算机性能监测程序

    progman--------程序管理器

    regedit----------注册表编辑器

    regedt32-------注册表编辑器

    regsvr32 /u *.dll----停止dll文件运行

    route print------查看路由表

    rononce -p ----15秒关机

    rsop.msc-------组策略结果集

    rundll32.exe rundll32.exe %Systemroot%System32shimgvw.dll,ImageView_Fullscreen----启动一个空白的Windows 图片和传真查看器

    secpol.msc--------本地安全策略

    services.msc---本地服务设置

    sfc /scannow-----启动系统文件检查器

    sndrec32-------录音机

    taskmgr-----任务管理器(适用于2000/xp/2003)

    tsshutdn-------60秒倒计时关机命令

    winchat--------XP自带局域网聊天

    winmsd---------系统信息

    winver-----显示About Windows 窗口

    wupdmgr-----------Windows Update

    Eclipse快捷键


    Ctrl+1 快速修复(最经典的快捷键,就不用多说了)
    Ctrl+D: 删除当前行
    Ctrl+Alt+↓ 复制当前行到下一行(复制增加)
    Ctrl+Alt+↑ 复制当前行到上一行(复制增加)

    Alt+↓ 当前行和下面一行交互位置(特别实用,可以省去先剪切,再粘贴了)
    Alt+↑ 当前行和上面一行交互位置(同上)
    Alt+← 前一个编辑的页面
    Alt+→ 下一个编辑的页面(当然是针对上面那条来说了)

    Alt+Enter 显示当前选择资源(工程,or 文件 or文件)的属性

    Shift+Enter 在当前行的下一行插入空行(这时鼠标可以在当前行的任一位置,不一定是最后)
    Shift+Ctrl+Enter 在当前行插入空行(原理同上条)

    Ctrl+Q 定位到最后编辑的地方
    Ctrl+L 定位在某行 (对于程序超过100的人就有福音了)
    Ctrl+M 最大化当前的Edit或View (再按则反之)
    Ctrl+/ 注释当前行,再按则取消注释
    Ctrl+O 快速显示 OutLine
    Ctrl+T 快速显示当前类的继承结构
    Ctrl+W 关闭当前Editer
    Ctrl+K 参照选中的Word快速定位到下一个
    Ctrl+E 快速显示当前Editer的下拉列表(如果当前页面没有显示的用黑体表示)

    Ctrl+/(小键盘) 折叠当前类中的所有代码

    Ctrl+×(小键盘) 展开当前类中的所有代码

    Ctrl+Space 代码助手完成一些代码的插入(但一般和输入法有冲突,可以修改输入法的热键,也可以暂用Alt+/来代替)

    Ctrl+Shift+E 显示管理当前打开的所有的View的管理器(可以选择关闭,激活等操作)

    Ctrl+J 正向增量查找(按下Ctrl+J后,你所输入的每个字母编辑器都提供快速匹配定位到某个单词,如果没有,则在stutes line中显示没有找到了,查一个单词时,特别实用,这个功能Idea两年前就有了)

    Ctrl+Shift+J 反向增量查找(和上条相同,只不过是从后往前查)

    Ctrl+Shift+F4 关闭所有打开的Editer

    Ctrl+Shift+X 把当前选中的文本全部变味小写

    Ctrl+Shift+Y 把当前选中的文本全部变为小写

    Ctrl+Shift+F 格式化当前代码

    Ctrl+Shift+P 定位到对于的匹配符(譬如{}) (从前面定位后面时,光标要在匹配符里面,后面到前面,则反之)

    下面的快捷键是重构里面常用的,本人就自己喜欢且常用的整理一下(注:一般重构的快捷键都是Alt+Shift开头的了)

    Alt+Shift+R 重命名 (是我自己最爱用的一个了,尤其是变量和类的Rename,比手工方法能节省很多劳动力)

    Alt+Shift+M 抽取方法 (这是重构里面最常用的方法之一了,尤其是对一大堆泥团代码有用)

    Alt+Shift+C 修改函数结构(比较实用,有N个函数调用了这个方法,修改一次搞定)

    Alt+Shift+L 抽取本地变量( 可以直接把一些魔法数字和字符串抽取成一个变量,尤其是多处调用的时候)

    Alt+Shift+F 把Class中的local变量变为field变量 (比较实用的功能)

    Alt+Shift+I 合并变量(可能这样说有点不妥Inline)
    Alt+Shift+V 移动函数和变量(不怎么常用)
    Alt+Shift+Z 重构的后悔药(Undo)

    2009年4月15日星期三

    如何获取Ext.form.FormPanel的load和submit事件

    在使用ExtJs.form.FormPanel的过程中,有很多时候需要获得装载数据完成时的事件,那么一般这种事件怎么获得呢?请看如下示例:


    Ext.getCmp('tabs').getForm().on("actioncomplete",
    function(from,action){
    if(action.type=="submit")
    {
    console.log(action.result)
    }
    })

    其中Ext.getCmp('tabs')
    是假设有一个id=‘tabs’的FormPanel。而action.type就是指事件(action)的类型。目前有两种分别为'submit'和'load'。

    Blogspot 代码引用

    在Html的CSS中加入如下

    CODE {
    border-bottom: 1px solid #AAAAAA;
    border-right: 1px solid #AAAAAA;
    display:block;padding: 10px 10px;
    padding-top: 20px;
    margin: 10px 0 0 10px;
    background:#F5F5F5;
    font-family:"Courier New", Courier, mono;
    -moz-border-radius: 15px;
    }
    CODE:hover {
    background-color:#F7FEDC;
    }

    虽然不能预览,但是用于可以引用代码了,太棒了。

    今年希望看完的书

    正在看的书:
    1. Programming Ruby
    2. The Ruby Way
    3. POJO In Action
    4. Hibernate In Action
    5. Java网络编程
    6. 重构
    7. 修改代码的艺术
    希望有时间去看的书(书都买了)
    1. Java优化编程(第2版)
    2. Flex3RIA开发详解
    3. 测试驱动开发
    需要看第二遍的好书
    1. Jdk6学习笔记
    2. Head First 设计模式
    3. css实战手册
    4. Agile Web Development with Rails
    5. Pro Spring

    Eclipse3.4的Ruby支持

    再Eclipse3.4之前的版本,我们可以用Aptana来编辑Ruby,但是升级到Eclipse3.4以后,还没有找到一个合适的plugin来写Ruby代码。今天再Eclipse Plugin Center终于找到了一个不错的Ruby Editor,但是目前还不支持Rails。Eclipse Update site为:http://download.eclipse.org/technology/dltk/updates/
    这个工具距离NetBeans还有不小的差距,但是终于也算有的用了,单元Aptana能快点更新。

    MySql 主键自动增长

    方法一:
    id int auto_increment not null,
    name varchar(100) null,
    primary key(id)
    方法二:
    ID integer primary key auto_increment not null,
    name varchar(100) null

    SpringSide3第一步

    因为SS3是建立再maven之上的,为了减少以后的麻烦,先建一个nexus私服。
    • 搭建nexus,下载nexus,我是直接再springside3 all in one 中的\tools\maven文件夹找到的,之后依次运行\tools\maven\nexus-1.2.1\nexus-webapp-1.2.1\bin\jsw\windows-x86-32目录下的InstallNexus.bat和StartNexus.bat。
    • 之后启动Tomcat。
    • 之后运行bin\quickstart.bat。
    • 之后去看会儿电视什么的。
    • 之后看看C盘C:\Documents and Settings\{UserName}\.m2目录下的repository就建好了。这时候的sample是运行再Derby上的,如果要运行再Mysql上,首先要改applicationContext.xml和application.properties.但是SS3的driverClassName为什么不也写到properties中呢?我也纳闷呢!。之后再去修改项目中的pom.xml。
    • demo中的schema sql是针对Derby的,所以为了方便操作,建立一个针对Mysql的脚本。再修改pom.xml.
      之后运行进入bin目录运行init_db.bat.再之后运行examples\mini-web\bin\copy-jar.bat再把它引入eclipse就可以了。

    搭建环境的时候可以参考springside3wiki这篇文章

    Ext.Window 问题总结

    Ext.Window 是Ext中最漂亮的widgets之一。但是在实际开发中问题多多。
    关于隐藏:
    • 问题:作为一个重量级widgets,为了减少资源的消耗,每当关闭时,window默认为隐藏模式,可是每次你再打开这个window的时候,会发现window中的数据(我的习惯是在window中嵌套formPanel,我所指的数据是formPanel中的数据)可能并没有变,或者说更新。其中大部分原因,要么是formPanel没有load数据,要么是window初始化的时候把某个数据传给了某个监听器或者handler,而再次打开window的时候,数据并没有传过去。
    • 办法1:这种办法就是不用隐藏,每次都打开,在关闭window的监听器中,或者关闭window的时候distroy这个对象,记住在这之前一定要把这个window中引用到的其他对象也要distroy掉,之后在把它们的引用设为null。办法比较土,但是管事,好使。这样做一定记住设置closeAction:'close'
    • 办法2 不distroy任何对象,把一种办法中出现混淆的变量以参数的形式传给handler。在这里一定要关注的是嵌套在windows中的formpanel中的隐藏域,load数据的时候一定要保证所有的field都是load出来的。最后加一个mask,保证load的完整性。closeAction:'hide'。

    今天开始关注SpringSide

    昨天晚上开始研究SS3,发现要想玩转SS3,首先要先会用maven(烦),下一步是将sample装进IDE,再看看sample中的code,研究一下为什么那么多人都说它好。之后利用SS3\bin中的tools生成一个项目,自己玩玩。
    最终的想法是利用JRuby开发Java项目。Ruby的语法优势+Java的社区优势=无敌。
    晚上推出第一部分内容。