随笔 - 8, 文章 - 0, 评论 - 4, 引用 - 0
数据加载中……

置顶随笔

[置顶]模式窗体关闭后调用父类窗体的方法

首先父窗有一个test()方法。
调用模式窗体window.showModalDialog('/test.html',window)   记得第二个参数一定要把父类窗体当参数传到模式窗体。

模式窗体加入事件
<script for="window" event="onunload">
    dialogArguments.window.test();  
</script>
这样就可以在模式窗体关闭或者是重载的时候调用父类窗体的方法,如果不想让重载的时候调用父窗体的test()方法,可以给父窗体传一个变量,到时候根据变量的值来判断是不是要执行test()方法。



posted @ 2007-05-07 17:04 Pitey 阅读(1374) | 评论 (0)编辑 收藏

2009年2月18日

Java静态代理和动态代理

网上和bolg上相关例子不少,今天自己动手写了个例子作为学习笔记。
首先java代理分为静态代理和动态代理,动态代理中java提供的动态代理需要动态代理一个inteface,如果没有inteface则需要使用实现cglib提供的接口。
下面例子只实现动态代理
public class MyProxy implements InvocationHandler{
    
    
static Object proxyObj = null;    
    
    
public static Object getInstance(Object obj){
        proxyObj
= obj;
        
return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), new MyProxy());
    }

    
    
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(
"使用代理..");
        
return method.invoke(proxyObj, args);
    }

}

实现方式
public static void main(String[] args) {
        ILeaveService service 
= (ILeaveService)MyProxy.getInstance(new LeaveServiceImpl());
        
try {
            service.listBizObjByHql(
"");
        }

        
catch (ServiceException e) {
            e.printStackTrace();
        }

    }

打印出:
使用代理..
query Hql..
使用Cglib
public class Test2 implements MethodInterceptor {
        
    
    
public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        System.out.println(
"cglib proxy");
        
return methodProxy.invokeSuper(obj, args);
    }

    
}

实现
public static void main(String[] args) {
        Enhancer enhancer 
= new  Enhancer();
        enhancer.setSuperclass(Test3.class);
        enhancer.setCallback(new Test2());        

        Test3 test 
= (Test3)enhancer.create();
        test.prinInfo(
"p.");
    }
输出
cglib proxy
p.
过滤器
public class Test4 implements CallbackFilter{

    
public int accept(Method method) {
        
if(method.getName().equals("method1")){
            
return 1;
        }
else if(method.getName().equals("method2")){
            
return 0;
        }

        
return 0;
    }

    
}
只有返回0的才执行(cglib中的NoOp.INSTANCE就是一个空的拦截器
    public static void main(String[] args) {        
        Callback [] callbacks 
= new Callback[]{new Test2(),NoOp.INSTANCE};
        Enhancer enhancer 
= new Enhancer();
        enhancer.setSuperclass(Test3.
class);
        enhancer.setCallbacks(callbacks);
        enhancer.setCallbackFilter(
new Test4());
        Test3 test3 
= (Test3)enhancer.create();
        test3.method1();
        test3.method2();
    }

    
}

执行结果
method1
cglib proxy
method2

posted @ 2009-02-18 16:52 Pitey 阅读(470) | 评论 (0)编辑 收藏

2009年2月11日

转:Message Driven POJO

作者:江南白衣 
  
    一直希望那些J字头的协议能有几个提前告老还乡的,好减轻一下我们的负担,特别是这WebService满天飞的时代。但似乎还有很久都轮不到JMS的消失:

    1.因为
    1.它是《Effective Enterprise Java》的一个实践。 
    可以把不影响用户执行结果又比较耗时的任务(比如发邮件通知管理员)异步的扔给JMS 服务端去做,而尽快的把屏幕返还给用户。
    而且服务端能够多线程排队响应--高并发的请求。

    2. 可以在Java世界里达到最高的解耦。
       对比WebService,JMS的客户端与服务端无需直连,甚至无需知晓对方是谁、在哪里、有多少人,只要对流过的信息作响应就行了。对牵一发动全身的企业应用来说很轻省。
       
     2. 但是
     1. Message Bean带着EJB系的荣光,步骤比较繁杂,你需要实现MessageDrivenBean、MessageListener接口,还需要设置EJB的配置信息,然后是deploy....

     2. Spring 1.x 提供的JMS Template简化了JMS Client端的编程,但并没有涉及到服务端的改造。

     3. 所以,SpringSide的Message Driven POJO方案

      Spring JMS Template + ActiveMQ + Jencks

1. 它是Lightweight的,基本上只是普通POJO,不用搞太多东西。

2. 它是Spring Base的,可以使用Spring的各种特性如IOC、AOP。

3. 它是Effective的,基于Jencks的JCA Container实现 pool connection,control transactions and manage security。

4. 但它是withdout EJB Container的。

其实它还不是100% POJO,除非再用上Lingo,但我已不想走得太远。

4.黄金版配置
      如果你想找一个ActiveMQ 3.2 Stable版+Spring的100%可行的配置文件,估计只能到SpringSide项目里看了。网上的文章,不是已过时,就是不切题。

     推荐中英两份最接近的文档:
     捷特慈朋(IDEA中国): Spring和Message Bean的整合
     Spring loaded:  Message-Driven POJOs 

     不过它们都有个outdate的地方--ActiveMQ3.2开始不再自带JCA Cotainer了,而是将其与Gernimo 合作而成了Jencks,需另外安装。

 5.SpringSide旅游指南

      pom.xml里的JMS部分 --所需的依赖包。
      applicationContext-jms.xml --黄金版配置文件。
      activemq.xml  --AcitveMQ Broker配置文件。
      OrderPlaceMDP.java --Message Driven Pojo。
      JmsTest.java --单元测试用例。
      OrderManger.java的NodifyOrder()函数 --实际应用的地方。 

 POJO太简单,唯一麻烦的配置文件已注释,这里也就无话了。

posted @ 2009-02-11 09:52 Pitey 阅读(236) | 评论 (0)编辑 收藏

[导入]一次Java垃圾收集调优实战

     摘要: GC调优是个很实验很伽利略的活儿,最后服务的处理速度从1180 tps 上升到1380 tps,调整两个参数提升17%的性能还是笔很划算的买卖.....  阅读全文

江南白衣 2008-07-09 10:13 发表评论

文章来源:http://www.blogjava.net/calvin/archive/2008/07/09/213535.html

posted @ 2009-02-11 09:17 Pitey 阅读(148) | 评论 (0)编辑 收藏

2009年2月10日

Spring事物拦截器学习笔记

Spring事物拦截器,按照通知方式分为[前置通知(Before advice),返回后通知(After returning advice)
,抛出后通知(After throwing advice),后通知(After (finally) advice),环绕通知(Around Advice)]
配置方式分@AspectJ,XML,网上比较多的是Spring1.1或xml+@AspectJ方式配置,例子使用XML方式配置

1.定义切面类接口,切面类实现这个接口。声明(如果被代理的目标对象实现了至少一个接口,则会使用JDK动态代理。所有该目标类型实现的接口都将被代理。若该目标对象没有实现任何接口,则创建一个CGLIB代理)

public interface ITestAdvice {
 
 
public void doPlay();
 
 
public void doStop(Object reval);

}



public class Tv implements ITestAdvice{
 
 
 
public void doStop(Object reval) {
  System.out.println(reval.toString() 
+ "关闭电视机!");
 }

 
 
public void doPlay() {
  System.out.println(
"打开电视机!");
 }

 
}


 

2.定义前置通知拦截处理类

 

public class TestMethodBeforeAdvice  {
 
 
public void before(JoinPoint jpt) {  //参数JoinPoint为默认参数
  System.out.println(
"正在打开电视..");
 }

 
}



3.定义拦截器配置文件

<bean id="tv" class="com.pitey.demo.Tv" />
<bean id="beforeAdvice" class="com.pitey.demo.TestMethodBeforeAdvice" />
 
 
<aop:aspectj-autoproxy proxy-target-class="true"/>
 
<aop:config>
  
<!-- 定义切入点 -->
  
<aop:pointcut id="methodAdvice" expression="execution(* com.pitey.demo.*.*(..))" />
  
<!-- 定义切面 -->
  
<aop:aspect id="beforeAdviceAspect" ref="beforeAdvice">
   
<!-- 定义前置通知 -->   
   
<aop:before method="before" pointcut-ref="methodAdvice"/>    
 
</aop:config>


4.测试一下前置通知

public static void main(String[] args) {
        ApplicationContext context 
= new ClassPathXmlApplicationContext("config\\advice.xml");
        Tv tv 
= (Tv)context.getBean("tv");
        tv.doPlay();        
    }


结果:
            正在打开电视机..
            打开电视机


5.定义返回后通知拦截处理类

public class TestAfterReturnAdvice {
 
 
public void afterReturning(Object retVal) throws Throwable {
  String returnVal 
= 电视机已经打开!";
  System.out.println(returnVal);
  retVal
= (Object)returnVal;
 }

 
}



6.定义拦截器配置文件

 

<bean id="afterReturnAdvice" class="com.pitey.demo.TestAfterReturnAdvice"/>
 
<aop:config>
  
<!-- 定义切面 -->
  
<aop:aspect id="afterReturnAdviceAspect" ref="afterReturnAdvice">
   
<!-- 定义后置返回通知  -->   
   
<aop:after-returning method="afterReturning" pointcut-ref="methodAdvice" returning="retVal"/> //returing 为返回参数
 </aop:config>


7.测试一下返回后通知

public static void main(String[] args) {
        ApplicationContext context 
= new ClassPathXmlApplicationContext("config\\advice.xml");
        Tv tv 
= (Tv)context.getBean("tv");
        tv.doPlay();        
    }


结果:
            正在打开电视机..
            打开电视机
            电视机已经打开
!


8.定义环绕通知拦截处理类(环绕通知在一个方法执行之前和之后执行。 它使得通知有机会既在一个方法执行之前又在执行之后运行。并且,它可以决定这个方法在什么时候执行,如何执行,甚至是否执行。 环绕通知经常在在某线程安全的环境下,你需要在一个方法执行之前和之后共享某种状态的时候使用。 请尽量使用最简单的满足你需求的通知。(比如如果前置通知(before advice)也可以适用的情况下不要使用环绕通知))
通知方法的第一个参数的类型必须是 ProceedingJoinPoint 类型。在通知的主体中,调用 ProceedingJoinPointproceed() 方法来执行真正的方法。 proceed 方法也可能会被调用并且传入一个 Object[] 对象 - 该数组将作为方法执行时候的参数。

public class TestMethodIntercepor{
 
 
public Object doBasicProfiling(ProceedingJoinPoint  pjp) throws Throwable {
  System.out.println(
"begining");
  Object obj 
= pjp.proceed();
  
  System.out.println(
"ending..");
  
return obj;
 }
 
}




9.定义拦截器配置文件

 

<bean id="aroundAdvice" class="com.pitey.demo.TestMethodIntercepor"/>
 
<aop:config>
  
<!-- 定义切面 -->
  
<aop:aspect id="aroundAspect" ref="aroundAdvice">
 
<aop:around method="doBasicProfiling" pointcut-ref="methodBeforeAdvice"/>
  
</aop:aspect>
 
</aop:config>



10.测试一下环绕通知

public static void main(String[] args) {
        ApplicationContext context 
= new ClassPathXmlApplicationContext("config\\advice.xml");
        Tv tv 
= (Tv)context.getBean("tv");
        tv.doPlay();        
    }


结果:
            begining
            打开电视机
            ending..

posted @ 2009-02-10 23:07 Pitey 阅读(1668) | 评论 (0)编辑 收藏

2008年3月18日

转:重写window.setTimeout传参数(支持传对象)的方法

也许你过去在setTimeout中传参数一直是这样

setTimeout("pass(" + argu + ")",1000)

这样只能传字符串,对传递object就无能为力了,需要大费文章.然而别忘了,第一个参数还可以是function!!!

看以下代码实现向里面的function 传参数

<script type="text/javascript">
var _st = window.setTimeout;window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == 'function'){ 
  var argu 
= Array.prototype.slice.call(arguments,2); 
  var f 
= (function(){ fRef.apply(null, argu); }); 
  return _st(f, mDelay); }
  return
 _st(fRef,mDelay);}

function test(x){ alert(x);}
window.setTimeout(test,
1000,'fason');
</
script>

怎样?是不是很方便了?代码其实就很简单,重载了一下window.setTimeout,用apply去回调前面的function.

还没有用过apply,call的可以去查资料,发现版本不够的看我低版本的实现方法http://blog.csdn.net/fason/archive/2004/07/30/apply_call.aspx

另外需要知道的是,NS环境下,后面的参数确实是来传给前面的函数的,IE烂,没有实现~~~~~~~~~~~~~

posted @ 2008-03-18 10:21 Pitey 阅读(3658) | 评论 (1)编辑 收藏

2008年3月17日

转document.execCommand()用法说明

document.execCommand()用法说明

2D
-Position 允许通过拖曳移动绝对定位的对象。
AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。
BackColor 设置或获取当前选中区的背景颜色。
BlockDirLTR 目前尚未支持。
BlockDirRTL 目前尚未支持。
Bold 切换当前选中区的粗体显示与否。
BrowseMode 目前尚未支持。
Copy 将当前选中区复制到剪贴板。
CreateBookmark 创建一个书签锚或获取当前选中区或插入点的书签锚的名称。
CreateLink 在当前选中区上插入超级链接,或显示一个对话框允许用户指定要为当前选中区插入的超级链接的 URL。
Cut 将当前选中区复制到剪贴板并删除之。
Delete 删除当前选中区。
DirLTR 目前尚未支持。
DirRTL 目前尚未支持。
EditMode 目前尚未支持。
FontName 设置或获取当前选中区的字体。
FontSize 设置或获取当前选中区的字体大小。
ForeColor 设置或获取当前选中区的前景(文本)颜色。
FormatBlock 设置当前块格式化标签。
Indent 增加选中文本的缩进。
InlineDirLTR 目前尚未支持。
InlineDirRTL 目前尚未支持。
InsertButton 用按钮控件覆盖当前选中区。
InsertFieldset 用方框覆盖当前选中区。
InsertHorizontalRule 用水平线覆盖当前选中区。
InsertIFrame 用内嵌框架覆盖当前选中区。
InsertImage 用图像覆盖当前选中区。
InsertInputButton 用按钮控件覆盖当前选中区。
InsertInputCheckbox 用复选框控件覆盖当前选中区。
InsertInputFileUpload 用文件上载控件覆盖当前选中区。
InsertInputHidden 插入隐藏控件覆盖当前选中区。
InsertInputImage 用图像控件覆盖当前选中区。
InsertInputPassword 用密码控件覆盖当前选中区。
InsertInputRadio 用单选钮控件覆盖当前选中区。
InsertInputReset 用重置控件覆盖当前选中区。
InsertInputSubmit 用提交控件覆盖当前选中区。
InsertInputText 用文本控件覆盖当前选中区。
InsertMarquee 用空字幕覆盖当前选中区。
InsertOrderedList 切换当前选中区是编号列表还是常规格式化块。
InsertParagraph 用换行覆盖当前选中区。
InsertSelectDropdown 用下拉框控件覆盖当前选中区。
InsertSelectListbox 用列表框控件覆盖当前选中区。
InsertTextArea 用多行文本输入控件覆盖当前选中区。
InsertUnorderedList 切换当前选中区是项目符号列表还是常规格式化块。
Italic 切换当前选中区斜体显示与否。
JustifyCenter 将当前选中区在所在格式化块置中。
JustifyFull 目前尚未支持。
JustifyLeft 将当前选中区所在格式化块左对齐。
JustifyNone 目前尚未支持。
JustifyRight 将当前选中区所在格式化块右对齐。
LiveResize 迫使 MSHTML 编辑器在缩放或移动过程中持续更新元素外观,而不是只在移动或缩放完成后更新。
MultipleSelection 允许当用户按住 Shift 或 Ctrl 键时一次选中多于一个站点可选元素。
Open 打开。
Outdent 减少选中区所在格式化块的缩进。
OverWrite 切换文本状态的插入和覆盖。
Paste 用剪贴板内容覆盖当前选中区。
PlayImage 目前尚未支持。
Print 打开打印对话框以便用户可以打印当前页。
Redo 重做。
Refresh 刷新当前文档。
RemoveFormat 从当前选中区中删除格式化标签。
RemoveParaFormat 目前尚未支持。
SaveAs 将当前 Web 页面保存为文件。
SelectAll 选中整个文档。
SizeToControl 目前尚未支持。
SizeToControlHeight 目前尚未支持。
SizeToControlWidth 目前尚未支持。
Stop 停止。
StopImage 目前尚未支持。
StrikeThrough 目前尚未支持。
Subscript 目前尚未支持。
Superscript 目前尚未支持。
UnBookmark 从当前选中区中删除全部书签。
Underline 切换当前选中区的下划线显示与否。
Undo 撤消。
Unlink 从当前选中区中删除全部超级链接。
Unselect 清除当前选中区的选中状态。

<HTML>

        
<HEAD>

            
<TITLE>JavaScript--execCommand指令集</TITLE>

            
<SCRIPT LANGUAGE="javascript">

<!--

/*

*该function执行copy指令

*/

function fn_doufucopy(){

edit.select();

document.execCommand(
'Copy');

}

/*

*该function执行paste指令

*/

function fn_doufupaste() {

tt.focus();

document.execCommand(
'paste');

}

/*

*该function用来创建一个超链接

*/

function fn_creatlink()

{

     document.execCommand(
'CreateLink',true,'true');//弹出一个对话框输入URL

     
//document.execCommand('CreateLink',false,'http://www.51js.com');

}

/*

*该function用来将选中的区块设为指定的背景色

*/

function fn_change_backcolor()

{

     document.execCommand(
'BackColor',true,'#FFbbDD');//true或false都可以

}

/*

*该function用来将选中的区块设为指定的前景色,改变选中区块的字体大小,改变字体,字体变粗变斜

*/

function fn_change_forecolor()

{

//指定前景色

document.execCommand(
'ForeColor',false,'#BBDDCC');//true或false都可以

//指定背景色

document.execCommand(
'FontSize',false,7);      //true或false都可以

//字体必须是系统支持的字体

document.execCommand(
'FontName',false,'标楷体');      //true或false都可以

//字体变粗

document.execCommand(
'Bold');

//变斜体

document.execCommand(
'Italic');

}

/*

*该function用来将选中的区块加上不同的线条

*/

function fn_change_selection()

{

//将选中的文字加下划线

document.execCommand(
'Underline');

//在选中的文字上划粗线

document.execCommand(
'StrikeThrough');

//将选中的部分文字变细

document.execCommand(
'SuperScript');

//将选中区块的下划线取消掉

document.execCommand(
'Underline');

}

/*

     *该function用来将选中的区块排成不同的格式

     
*/

function fn_format()

{

//有序列排列

document.execCommand(
'InsertOrderedList');

//实心无序列排列

document.execCommand(
'InsertUnorderedList');

//空心无序列排列

document.execCommand(
'Indent');

}

/*

*该function用来将选中的区块剪下或是删除掉

*/

function fn_CutOrDel()

{

//删除选中的区块

//document.execCommand('Delete');

//剪下选中的区块

document.execCommand(
'Cut');

}

/*

*该function用来将选中的区块重设为一个相应的物件

*/

function fn_InsObj()

{

/*

     ******************************************

     * 以下指令都是为选中的区块重设一个object;

     * 如没有特殊说明,第二个参数true或false是一样的;

     * 参数三表示为该object的id;

     * 可以用在javascript中通过其指定的id来控制它

     ******************************************

*/

/*重设为一个button(InsertButton和InsertInputButtong一样,

只不前者是button,后者是input)
*/

/*document.execCommand('InsertButton',false,"aa"); //true或false无效

document.all.aa.value="风舞九天";
*/

//重设为一个fieldset

/*document.execCommand('InsertFieldSet',true,"aa");

document.all.aa.innerText="刀剑如梦";
*/

//插入一个水平线

//document.execCommand('InsertHorizontalRule',true,"aa");

//插入一个iframe

//document.execCommand('InsertIFrame',true,"aa");

//插入一个InsertImage,设为true时需要图片,false时不需图片

//document.execCommand('InsertImage',false,"aa");

//插入一个checkbox

//document.execCommand('InsertInputCheckbox',true,"aa");

//插入一个file类型的object

//document.execCommand('InsertInputFileUpload',false,"aa");

//插入一个hidden

/*document.execCommand('InsertInputHidden',false,"aa");

alert(document.all.aa.id);
*/

//插入一个InputImage

/*document.execCommand('InsertInputImage',false,"aa");

document.all.aa.src="F-a10.gif";
*/

//插入一个Password

//document.execCommand('InsertInputPassword',true,"aa");

//插入一个Radio

//document.execCommand('InsertInputRadio',false,"aa");

//插入一个Reset

//document.execCommand('InsertInputReset',true,"aa");

//插入一个Submit

//document.execCommand('InsertInputSubmit',false,"aa");

//插入一个input text

//document.execCommand('InsertInputText',false,"aa");

//插入一个textarea

//document.execCommand('InsertTextArea',true,"aa");

//插入一个 select list box

//document.execCommand('InsertSelectListbox',false,"aa");

//插入一个single select

document.execCommand(
'InsertSelectDropdown',true,"aa");

//插入一个line break(硬回车??)

//document.execCommand('InsertParagraph');

//插入一个marquee

/*document.execCommand('InsertMarquee',true,"aa");

document.all.aa.innerText="bbbbb";
*/

//用于取消选中的阴影部分

//document.execCommand('Unselect');

//选中页面上的所有元素

//document.execCommand('SelectAll');

}

/*

*该function用来将页面保存为一个文件

*/

function fn_save()

{

//第二个参数为欲保存的文件名

document.execCommand(
'SaveAs','mycodes.txt');

//打印整个页面

//document.execCommand('print');

}

-->

            
</SCRIPT>

        
</HEAD>

        
<body>

            
<input id="edit" value="范例" NAME="edit"><br>

            
<button onclick="fn_doufucopy()" ID="Button1">Copy</button> <button onclick="fn_doufupaste()" ID="Button2">

                 paste
</button><br>

            
<textarea id="tt" rows="10" cols="50" NAME="tt"></textarea>

            
<hr>

            
<br>

            浮沉聚散变化又再,但是总可卷土重来.
<br>

            天若有情天亦老,人间正道是沧桑.
<br>

            都怪我,太执着,却也等不到花开叶落.
<br>

            
<br>

            Please select above letters, then click following buttons:
<br>

            
<hr>

            
<input type="button" value="创建CreateLink" onclick="fn_creatlink()" ID="Button3" NAME="Button3"><br>

            
<input type="button" value="改变文字背景色" onclick="fn_change_backcolor()" ID="Button4" NAME="Button4"><br>

            
<input type="button" value="改变文字前景色" onclick="fn_change_forecolor()" ID="Button5" NAME="Button5"><br>

            
<input type="button" value="给文字加线条" onclick="fn_change_selection()" ID="Button6" NAME="Button6"><br>

            
<input type="button" value="改变文字的排列" onclick="fn_format()" ID="Button7" NAME="Button7"><br>

            
<input type="button" value="删除或剪下选中的部分" onclick="fn_CutOrDel()" ID="Button8" NAME="Button8"><br>

            
<input type="button" value="插入Object" onclick="fn_InsObj()" ID="Button9" NAME="Button9"><br>

            
<input type="button" value="保存或打印文件" onclick="fn_save()" ID="Button10" NAME="Button10"><br>

            
<input type="button" value="测试Refresh属性" onclick="document.execCommand('Refresh')" ID="Button11"

                 NAME
="Button11">

        
</body>

</HTML>

普通的方式是激活一个
<iframe>进入编辑状态,命令如下

IframeNamer.document.designMode
="On"

字体
--宋体、黑体、楷体等

execCommand(
"fontname","",字体)

字号
--字号大小

execCommand(
"fontsize","",字号)

加重

execCommand(
"Bold")

斜体

execCommand(
"Italic")

下划线

execCommand(
"Underline")

删除线

execCommand(
"StrikeThrough")

上标

execCommand(
"SuperScript")

下标

execCommand(
"SubScript")

有序排列
--数字序号

execCommand(
"InsertOrderedList")

无序排列
--圆点序号

execCommand(
"InsertUnorderedList")

向前缩进

execCommand(
"Outdent")

向后缩进

execCommand(
"Indent")

居左

execCommand(
"JustifyLeft")

居右

execCommand(
"JustifyRight")

居中

execCommand(
"JustifyCenter")

剪切

execCommand(
"Cut")

拷贝

execCommand(
"Copy")

粘贴

execCommand(
"Paste")

覆盖

execCommand(
"Overwrite")

取消操作
--IE5.0以后可以无限取消

execCommand(
"Undo")

重复操作

execCommand(
"Redo")

设置链接
--若按以下写法,在IE5.0版本中会激活一个内建窗口,可以完成输入链接的功能,而且还可以选择MAILTO、FTP等各种链接类型,比较方便

execCommand(
"CreateLink")

在IE4.0中,没有内建链接输入窗口,所以就需要用以下方式嵌入链接

execCommand(
"CreateLink","",TURL)

插入图片
--由于IE中嵌入的可编控件是针对本地资源的,所以其默认的图片资源来自本地,所以基于WEB内容的编辑最好自己做输入框,然后用如下命令实现。

execCommand(
"InsertImage","",ImgURL)

字体颜色

execCommand(
"ForeColor","",CColor)

posted @ 2008-03-17 21:18 Pitey 阅读(610) | 评论 (0)编辑 收藏

2008年3月9日

获取 Iframe内的元素对象

例子:
 获得ifream的对象,并把ifreame中页面<div id="my">隐藏掉

test1.html

<html>
<head>
<script>
function t(){
var dd = document.all('test2').contentWindow.document;
dd.getElementById('my').style.display='none';

}
</script>
</head>
<body >
<input type="button" value="test" onClick="t();"/>
<iframe id="test2" name="test2" src="test2.html"></iframe>
</body>
</html>

test2.html
<html>
<head>
</head>
<body>
    
    
<div id="my" name="my">
       测试一下,父窗体可以把我隐藏掉!!!!!!!!
  
</div>
</body>
</html>



posted @ 2008-03-09 13:48 Pitey 阅读(7562) | 评论 (2)编辑 收藏

2008年3月5日

Spring 获取Connection

applicationContext.xml里面设置

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="default" autowire="default" dependency-check="default">
        <property name="jndiName">
            <value>JDBC/TEST</value>           
        </property>
</bean> 或者

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
        <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:ora"></property>
        <property name="username" value="test"></property>
        <property name="password" value="123456"></property>
    </bean>


通过
DataSourceUtils.getConnection(DataSource);就能获取到设置的DataSource 然后获得connection

public static Connection getConnection()
            
throws SQLException
    {        
        
return DataSourceUtils.getConnection((DataSource)ServiceLocator.getBean("dataSource"));
}

posted @ 2008-03-05 12:45 Pitey 阅读(3962) | 评论 (1)编辑 收藏

2007年5月7日

模式窗体关闭后调用父类窗体的方法

首先父窗有一个test()方法。
调用模式窗体window.showModalDialog('/test.html',window)   记得第二个参数一定要把父类窗体当参数传到模式窗体。

模式窗体加入事件
<script for="window" event="onunload">
    dialogArguments.window.test();  
</script>
这样就可以在模式窗体关闭或者是重载的时候调用父类窗体的方法,如果不想让重载的时候调用父窗体的test()方法,可以给父窗体传一个变量,到时候根据变量的值来判断是不是要执行test()方法。



posted @ 2007-05-07 17:04 Pitey 阅读(1374) | 评论 (0)编辑 收藏