|
置頂隨筆
首先父窗有一個test()方法。
調用模式窗體window.showModalDialog('/test.html',window) 記得第二個參數一定要把父類窗體當參數傳到模式窗體。
模式窗體加入事件
<script for="window" event="onunload">
dialogArguments.window.test();
</script>
這樣就可以在模式窗體關閉或者是重載的時候調用父類窗體的方法,如果不想讓重載的時候調用父窗體的test()方法,可以給父窗體傳一個變量,到時候根據變量的值來判斷是不是要執行test()方法。
2009年2月18日
網上和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 .");
}
輸出
過濾器
 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
2009年2月11日
作者: 江南白衣
一直希望那些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太簡單,唯一麻煩的配置文件已注釋,這里也就無話了。
摘要: GC調優是個很實驗很伽利略的活兒,最后服務的處理速度從1180 tps 上升到1380 tps,調整兩個參數提升17%的性能還是筆很劃算的買賣..... 閱讀全文
文章來源: http://www.tkk7.com/calvin/archive/2008/07/09/213535.html
2009年2月10日
2008年3月18日
也許你過去在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爛,沒有實現~~~~~~~~~~~~~
2008年3月17日
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)
2008年3月9日
例子:
獲得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>
2008年3月5日
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"));
}
2007年5月7日
首先父窗有一個test()方法。
調用模式窗體window.showModalDialog('/test.html',window) 記得第二個參數一定要把父類窗體當參數傳到模式窗體。
模式窗體加入事件
<script for="window" event="onunload">
dialogArguments.window.test();
</script>
這樣就可以在模式窗體關閉或者是重載的時候調用父類窗體的方法,如果不想讓重載的時候調用父窗體的test()方法,可以給父窗體傳一個變量,到時候根據變量的值來判斷是不是要執行test()方法。
|