亚洲国产成人五月综合网,亚洲另类春色国产精品,亚洲免费二区三区http://www.tkk7.com/rain1102/category/37626.html<br/><font color="green" style="font-family: 華文行楷;font-size:16px;">化學結(jié)構(gòu)搜索,化學信息學,生物信息學,實驗室信息學等 。</font><br/><font color="#3C1435">以高科技的生物、化學信息技術(shù)實現(xiàn)生命科學領(lǐng)域中專業(yè)數(shù)據(jù)的計算和管理、提高研發(fā)能力、增強在科研和成本效率方面的國際競爭力,為生物、化學、醫(yī)藥和學術(shù)機構(gòu)提供一流的解決方案和技術(shù)咨詢。</font><br/> <br/><font color="green" style="font-family: 華文行楷;font-size:16px;">子曰:危邦不入,亂邦不居。天下有道則見,無道則隱。</font><font color="#3C1435"></font><br/> zh-cnThu, 31 Mar 2011 13:19:08 GMTThu, 31 Mar 2011 13:19:08 GMT60高性能網(wǎng)站建設(shè)-示例http://www.tkk7.com/rain1102/archive/2011/03/31/347381.htmlEric.ZhouEric.ZhouThu, 31 Mar 2011 05:29:00 GMThttp://www.tkk7.com/rain1102/archive/2011/03/31/347381.htmlhttp://www.tkk7.com/rain1102/comments/347381.htmlhttp://www.tkk7.com/rain1102/archive/2011/03/31/347381.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/347381.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/347381.htmlhttp://stevesouders.com/hpws/rules.php

Eric.Zhou 2011-03-31 13:29 發(fā)表評論
]]>
jQuery獲取重名input的數(shù)組值http://www.tkk7.com/rain1102/archive/2011/03/29/347165.htmlEric.ZhouEric.ZhouTue, 29 Mar 2011 01:22:00 GMThttp://www.tkk7.com/rain1102/archive/2011/03/29/347165.htmlhttp://www.tkk7.com/rain1102/comments/347165.htmlhttp://www.tkk7.com/rain1102/archive/2011/03/29/347165.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/347165.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/347165.html var usernames = new Array();   
 var i = 0;  
$("input[name='username']").each(  
            function(){  
                usernames[i] = $(this).val();   
                i++;  
            }   
 )


Eric.Zhou 2011-03-29 09:22 發(fā)表評論
]]>
jQuery的Validation插件[轉(zhuǎn)載]http://www.tkk7.com/rain1102/archive/2010/01/25/310783.htmlEric.ZhouEric.ZhouMon, 25 Jan 2010 13:04:00 GMThttp://www.tkk7.com/rain1102/archive/2010/01/25/310783.htmlhttp://www.tkk7.com/rain1102/comments/310783.htmlhttp://www.tkk7.com/rain1102/archive/2010/01/25/310783.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/310783.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/310783.html

jQuery的Validation插件

最新最全的jQuery插件可以從jQuery的官方網(wǎng)站上面獲得,jQuery下載驗證插件的地址是http://plugins.jquery.com/在打開頁面的左上角’Search’框中輸入validation就可以找到我們想要的驗證插件了,在http://plugins.jquery.com/project/validate下,我們找到了目前最新的版本(2009年6月17日)官方推出的1.5.5版的validate.js.

Validation插件式歷史悠久的jQuery插件之一,經(jīng)過了全球各種項目的驗證,得到了很多WEB開發(fā)者的好評,作為一個表單驗證的解決方案,Validation有很多的優(yōu)點,比如:內(nèi)置的驗證規(guī)則,可以自定義驗證規(guī)則,簡單而且強大的驗證信息提示,實時進行驗證的功能.都可以令前臺開發(fā)變得非常的簡單.Validation具有內(nèi)置的必填,數(shù)字,Email,URL等多種驗證規(guī)則.實時驗證方面,通過blur和keyup時間來觸發(fā)驗證規(guī)則,可以達到實時驗證的目的.

下面是一個簡單的例子,HTML和jQuery代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

       <title>jQuery之驗證插件</title>

       <script type='text/javascript' src='jquery-1.3.2.js'></script>

       <!-- 引入了jQuery庫之后,繼續(xù)引入validation插件 -->

       <script type='text/javascript' src='jquery.validate.js'></script>

       <style type='text/css'>

           *{font-family:Verdana;font-size:96%;}

           label.error{float:none;color:red;padding-left:.5em;vertical-align:top;}

           p{clear:both;}

           .submit{margin-left:12em;}

           em{font-weight:bold;vertical-align:top;}

       </style>

       <script type='text/javascript'>

           $(document).ready(function(){

              //確定哪一個表單需要進行驗證

              $('#commentForm').validate();

           });

       </script>

    </head>

    <body>

       <form class='cmxform' id='commentForm' method='get' action='#'>

           <fieldset>

              <legend>一個簡單的帶有提示的評論例子</legend>

              <p>

                  <label for='cusername'>姓名</label><em>*</em>

                  <!-- 針對不同的字段,進行驗證規(guī)則編碼,設(shè)置字段相應的屬性 -->

                  <!-- class='required'來設(shè)置必填驗證,minlength='2'設(shè)置最小長度驗證 -->

                  <input id='cusername' name='username' size='25' class='required' minlength='2'/>

              </p>

              <p>

                  <label for='cemail'>電子郵件</label><em>*</em>

                  <!-- class='required,email'為必填內(nèi)容和email規(guī)則驗證 -->

                  <input id='cemail' name='email' size='25' class='required email'/>

              </p>

              <p>

                  <label for='curl'>網(wǎng)址</label><em>*</em>

                  <!-- class='url'設(shè)置url驗證 -->

                  <input id='curl' name='url' size='25' class='url' value=''/>

              </p>

              <p>

                  <label for='ccomment'>你的評論</label><em>*</em>

                  <!-- 對評論textarea進行必填驗證 -->

                  <textarea id='ccomment' name='comment' cols='25' class='required'></textarea>

              </p>

              <p>

                  <input class='submit' type='submit' value='提交'>

              </p>

           </fieldset>

       </form>

    </body>

</html>

上面的代碼實現(xiàn)了如下的驗證:

1)      對”姓名”的必填和長度至少為2為的驗證

2)      對”電子郵件”的驗證和是否為E-mail格式的驗證

3)      對”網(wǎng)址”是否為url的驗證

4)      對”你的評論”的必填驗證

5)      提供了在用戶輸入的時候?qū)﹂L度的實時驗證

只需要完成如下幾步,就可以將一個普通的表單變成一個可以進行驗證的表單:

1)      引入jQuery庫和Validation插件


view plaincopy to clipboardprint?
<mce:script type='text/javascript' src="jquery-1.3.2.js" mce_src="jquery-1.3.2.js"></mce:script> 
 
<!-- 引入了jQuery庫之后,繼續(xù)引入validation插件 --> 
 
<mce:script type='text/javascript' src="jquery.validate.js" mce_src="jquery.validate.js"></mce:script> 
<mce:script type='text/javascript' src="jquery-1.3.2.js" mce_src="jquery-1.3.2.js"></mce:script>

<!-- 引入了jQuery庫之后,繼續(xù)引入validation插件 -->

<mce:script type='text/javascript' src="jquery.validate.js" mce_src="jquery.validate.js"></mce:script>
 

2)      確定是哪一個表單需要被驗

 

view plaincopy to clipboardprint?
$(document).ready(function(){  
 
//確定哪一個表單需要進行驗證  
 
$('#commentForm').validate();  
 
}); 
$(document).ready(function(){

//確定哪一個表單需要進行驗證

$('#commentForm').validate();

});
 

3)      針對不同的字段,進行驗證規(guī)則的編碼,設(shè)置字段相應的屬性


view plaincopy to clipboardprint?
<input id='cusername' name='username' size='25' class='required' minlength='2'/> 
 
<input id='cemail' name='email' size='25' class='required email'/> 
 
<textarea id='ccomment' name='comment' cols='25' class='required'/> 
<input id='cusername' name='username' size='25' class='required' minlength='2'/>

<input id='cemail' name='email' size='25' class='required email'/>

<textarea id='ccomment' name='comment' cols='25' class='required'/>
 

將所有的驗證規(guī)則寫到class屬性里:

在實際的開發(fā)中,有的時候?qū)Ⅱ炞C規(guī)則寫到class=’required email’有的時候?qū)懙絤inlength=’2’里面,這樣非常的不方便,有沒有一種方式可以將所有的驗證規(guī)則放到一個地方去呢?這個答案是肯定的.jQuery充分考慮到了這一點,我們可以通過另外一個JavaScript庫來將所有的驗證規(guī)則放到一個class文件當中去.這樣就大大方面了對驗證規(guī)則的管理.

1)              在下載的\jquery-validate\lib文件夾下面找到j(luò)query.metadata.js.放到項目當中,然后引入該jQuery插件.jquery.metadate.js是一個支持固定格式解析的jQuery插件,Validation插件將其很好的融合到驗證規(guī)則編碼當中.

view plaincopy to clipboardprint?
<mce:script type="text/javascript" src="jquery.metadata.js" mce_src="jquery.metadata.js"></mce:script> 
<mce:script type="text/javascript" src="jquery.metadata.js" mce_src="jquery.metadata.js"></mce:script>

2)              改變調(diào)用的驗證方法

 

view plaincopy to clipboardprint?
<mce:script type='text/javascript'><!--  
    $(document).ready(function(){  
 
       //確定那個表單進行驗證(改變調(diào)用的驗證方法)  
 
       $('#commentForm').validate({meta: "validate"});  
 
    });  
// --></mce:script> 
<mce:script type='text/javascript'><!--
    $(document).ready(function(){

       //確定那個表單進行驗證(改變調(diào)用的驗證方法)

       $('#commentForm').validate({meta: "validate"});

    });
// --></mce:script>
 

3)              將所有的驗證規(guī)則都通過類似{validate:{required:true,email:true}}的形式,寫到class屬性當中,詳細的HTML代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

       <title>jQuery之驗證插件</title>

       <script type='text/javascript' src='jquery-1.3.2.js'></script>

       <!-- 引入了jQuery庫之后,繼續(xù)引入validation插件 -->

       <script type='text/javascript' src='jquery.validate.js'></script>

       <!-- 引入一個新的jQuery插件 -->

       <script type="text/javascript" src='jquery.metadata.js'></script>

       <style type='text/css'>

           *{font-family:Verdana;font-size:96%;}

           label.error{float:none;color:red;padding-left:.5em;vertical-align:top;}

           p{clear:both;}

           .submit{margin-left:12em;}

           em{font-weight:bold;vertical-align:top;}

       </style>

       <script type='text/javascript'>

           $(document).ready(function(){

              //確定那個表單進行驗證(改變調(diào)用的驗證方法)

              $('#commentForm').validate({meta: "validate"});

           });

       </script>

    </head>

    <body>

       <form class='cmxform' id='commentForm' method='get' action='#'>

           <fieldset>

              <legend>一個簡單的帶有提示的評論例子</legend>

              <p>

                  <label for='cusername'>姓名</label><em>*</em>

                  <input id='cusername' name='username' size='25' class='{validate:{required:true,minlength:2}}'/>

              </p>

              <p>

                  <label for='cemail'>電子郵件</label><em>*</em>

                  <input id='cemail' name='email' size='25' class='{validate:{required:true,email:true}}'/>

              </p>

              <p>

                  <label for='curl'>網(wǎng)址</label><em>*</em>

                  <input id='curl' name='url' size='25' class='{validate:{url:true}}' value=''/>

              </p>

              <p>

                  <label for='ccomment'>你的評論</label><em>*</em>

                  <textarea id='ccomment' name='comment' cols='25' class='{validate:{required:true}}'></textarea>

              </p>

              <p>

                  <input class='submit' type='submit' value='提交'>

              </p>

           </fieldset>

       </form>

    </body>

</html>

將驗證行為和HTML結(jié)構(gòu)完全脫離的一種驗證寫法:

上面的兩種寫法,一種是通過給標簽添加屬性來完成驗證,一種是通過jquery.metadate.js的幫助將所有的驗證規(guī)則添加到class屬性中,都沒有符合jQuery提倡的”行為和操作分離”的一個原則,下面的方法就補足了這個缺陷,可以讓HTML結(jié)構(gòu)和驗證規(guī)則很好的分離出來

HTML代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

       <title>jQuery之驗證插件</title>

       <script type='text/javascript' src='jquery-1.3.2.js'></script>

       <!-- 引入了jQuery庫之后,繼續(xù)引入validation插件 -->

       <script type='text/javascript' src='jquery.validate.js'></script>

       <style type='text/css'>

           *{font-family:Verdana;font-size:96%;}

           label.error{float:none;color:red;padding-left:.5em;vertical-align:top;}

           p{clear:both;}

           .submit{margin-left:12em;}

           em{font-weight:bold;vertical-align:top;}

       </style>

       <script type='text/javascript'>

           $(document).ready(function(){

              $('#commentForm').validate({

                  rules:{

                     username:{

                         required:true,

                         minlength:3

                     },

                     email:{

                         required:true,

                         email:true

                     },

                     url:"url",

                     comment:"required"

                  }

              })

           });

       </script>

    </head>

    <body>

       <form class='cmxform' id='commentForm' method='get' action='#'>

           <fieldset>

              <legend>一個簡單的帶有提示的評論例子</legend>

              <p>

                  <label for='cusername'>姓名</label><em>*</em>

                  <input id='cusername' name='username' size='25' />

              </p>

              <p>

                  <label for='cemail'>電子郵件</label><em>*</em>

                  <input id='cemail' name='email' size='25' />

              </p>

              <p>

                  <label for='curl'>網(wǎng)址</label><em>*</em>

                  <input id='curl' name='url' size='25' value=''/>

              </p>

              <p>

                  <label for='ccomment'>你的評論</label><em>*</em>

                  <textarea id='ccomment' name='comment' cols='25'></textarea>

              </p>

              <p>

                  <input class='submit' type='submit' value='提交'>

              </p>

           </fieldset>

       </form>

    </body>

</html>

在這種”HTML和驗證完全分離”的驗證規(guī)則寫法的步驟如下:

1)      在$(“#ccommentForm”).validate()方法中增加rules屬性

2)      通過每個字段的name屬性來匹配驗證規(guī)則

3)      定義驗證規(guī)則,比如required:true,email:true,minlength:2等等.

將默認的英文驗證信息變成中文:

validation插件默認的驗證信息是英文的,要想將validation驗證插件給出的驗證信息變成中文就可以到j(luò)query-validate\localization文件夾下面找到messages_cn.js文件,這個就是中文的驗證信息庫,我們只需要在代碼中將這個文件導入就可以實現(xiàn)中文驗證信息的輸出了.在jquery-validate\localization這個文件夾下面,還有很多種語言,我們可以選擇適當?shù)恼Z言引入到我們的項目當中,實現(xiàn)提示信息的本地化.

view plaincopy to clipboardprint?
<!-- 引入中文驗證信息庫 --> 
 
<mce:script type='text/javascript' src="messages_cn.js" mce_src="messages_cn.js"></mce:script> 
<!-- 引入中文驗證信息庫 -->

<mce:script type='text/javascript' src="messages_cn.js" mce_src="messages_cn.js"></mce:script>
 

 

改變千篇一律的驗證信息:

validaion驗證插件可以非常方便的進行自定義驗證規(guī)則,這樣可以用來代替千篇一律的驗證信息,具體修改好的HTML代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

       <title>jQuery之驗證插件</title>

       <script type='text/javascript' src='jquery-1.3.2.js'></script>

       <!-- 引入了jQuery庫之后,繼續(xù)引入validation插件 -->

       <script type='text/javascript' src='jquery.validate.js'></script>

       <!-- 引入中文驗證信息庫 -->

       <script type='text/javascript' src='messages_cn.js'></script>

       <!-- 要將所有的驗證規(guī)則放到css標簽當中去,就要引入metadate.js -->

       <script type='text/javascript' src='jquery.metadata.js'></script>

       <style type='text/css'>

           *{font-family:Verdana;font-size:96%;}

           label.error{float:none;color:red;padding-left:.5em;vertical-align:top;}

           p{clear:both;}

           .submit{margin-left:12em;}

           em{font-weight:bold;vertical-align:top;}

       </style>

       <script type='text/javascript'>

           $(document).ready(function(){

              $('#commentForm').validate({meta:"validate"});

           });

       </script>

    </head>

    <body>

       <form class='cmxform' id='commentForm' method='get' action='#'>

           <fieldset>

              <legend>一個簡單的帶有提示的評論例子</legend>

              <p>

                  <label for='cusername'>姓名</label><em>*</em>

                  <input id='cusername' name='username'

                      class="{validate:{required:true,minlength:2,messages:{

                     required:'姓名是必須要輸入的',

                     minlength:'請輸入不少于兩個字符的姓名'}}}"

                     size='25' />

              </p>

              <p>

                  <label for='cemail'>電子郵件</label><em>*</em>

                  <input id='cemail' name='email'

                      class="{validate:{required:true,email:true,messages:{

                     required:'郵箱是必須要輸入的',

                     email:'請輸入符合格式的Email地址'}}}"

                     size='25' />

              </p>

              <p>

                  <label for='curl'>網(wǎng)址</label><em>*</em>

                  <input id='curl' name='url'

                      class="{validate:{url:true,messages:{

                     url:'您的URL地址的輸入不符合要求'}}}"

                     size='25' value=''/>

              </p>

              <p>

                  <label for='ccomment'>你的評論</label><em>*</em>

                  <textarea id='ccomment' name='comment'

                  class="{validate:{

                  required:true,messages:{required:'多少也寫點評論哦'}}}"

                  cols='25'></textarea>

              </p>

              <p>

                  <input class='submit' type='submit' value='提交'>

              </p>

           </fieldset>

       </form>

    </body>

</html>

具體來說,上面的代碼就是在class的屬性中增加了類似messages:{required:’’,email:’’}形式的一塊代碼,這樣就可以顯示我們自定義的驗證信息了.

自己來定義表單驗證的業(yè)務(wù)規(guī)則:

通常在開發(fā)項目中,驗證規(guī)則與實際的業(yè)務(wù)邏輯是息息相關(guān)的,一個好的驗證插件必須要支持自定義驗證機制,當然jQuery就提供了多種機制來滿足用戶的業(yè)務(wù)需要.

我們添加以下代碼到上面的HTML代碼中,方便進行驗證碼的功能實現(xiàn).

 

 view plaincopy to clipboardprint?
<p> 
 
    <label for='cvalcode'>驗證碼</label> 
 
    <input id='cvalcode' name='valcode' size='25' value=''/>=7+9  
 
</p> 
<p>

    <label for='cvalcode'>驗證碼</label>

    <input id='cvalcode' name='valcode' size='25' value=''/>=7+9

</p>
 

為了實現(xiàn)”驗證碼”的功能,我們需要以下幾個步驟:

1)      自定義一個驗證規(guī)則

view plaincopy to clipboardprint?
$.validator.addMethod(  
 
    "formula",                       //驗證方法的名稱  
 
    function(value,element,param){   //驗證規(guī)則  
 
       return value==eval(param);   
 
       },  
 
      '請輸入正確的結(jié)果'                //提示驗證信息  
 
);  
$.validator.addMethod(

    "formula",                       //驗證方法的名稱

    function(value,element,param){   //驗證規(guī)則

       return value==eval(param);

       },

      '請輸入正確的結(jié)果'                //提示驗證信息

);
 


 

       2)      在代碼中引用以上驗證規(guī)則

view plaincopy to clipboardprint?
$('#commentForm').validate({  
 
    rules:{  
 
       username:{  
 
           required:true,  
 
           minlength:3  
 
       },  
 
       email:{  
 
           required:true,  
 
           email:true  
 
       },  
 
       url:"url",  
 
       comment:"required",  
 
       valcode:{formula:"7+9"}  
 
    }  
 
}) 

 

本文來自CSDN博客,轉(zhuǎn)載請標明出處:http://blog.csdn.net/ziwen00/archive/2009/09/14/4551346.aspx



Eric.Zhou 2010-01-25 21:04 發(fā)表評論
]]>
Extjs-displayfield格式化日期http://www.tkk7.com/rain1102/archive/2009/11/30/304320.htmlEric.ZhouEric.ZhouMon, 30 Nov 2009 14:25:00 GMThttp://www.tkk7.com/rain1102/archive/2009/11/30/304320.htmlhttp://www.tkk7.com/rain1102/comments/304320.htmlhttp://www.tkk7.com/rain1102/archive/2009/11/30/304320.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/304320.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/304320.html     getValue : function(){
        return this.value;
    },
    setValue : function(v){
        this.value = v;
        this.setRawValue(this.formatValue(v));
        return this;
    },
    formatValue : function(v){
     if(this.dateFormat && Ext.isDate(v)){
      return v.dateFormat(this.dateFormat);
     }
     if(this.numberFormat && typeof v == 'number'){
      return Ext.util.Format.number(v, this.numberFormat);
     }
     return v;
    }
});


items:[{
     fieldLabel:'申購日期',
     xtype : 'displayfield',
     name : 'orderDate',
     formatValue: function(value){return new Date(value).format("Y-m-d");}
    }]

Eric.Zhou 2009-11-30 22:25 發(fā)表評論
]]>
ExtJS的xtype列表http://www.tkk7.com/rain1102/archive/2009/11/20/303005.htmlEric.ZhouEric.ZhouFri, 20 Nov 2009 01:04:00 GMThttp://www.tkk7.com/rain1102/archive/2009/11/20/303005.htmlhttp://www.tkk7.com/rain1102/comments/303005.htmlhttp://www.tkk7.com/rain1102/archive/2009/11/20/303005.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/303005.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/303005.html原文地址:http://www.tkk7.com/sealyu/archive/2009/11/18/302849.html

xtype                  Class            

基本組件:                                                                 

box                    Ext.BoxComponent                      具有邊框?qū)傩缘慕M件

button                Ext.Button                                      按鈕

colorpalette      Ext.ColorPalette                            調(diào)色板

component       Ext.Component                            組件

container          Ext.Container                                容器

cycle                 Ext.CycleButton

dataview          Ext.DataView                                數(shù)據(jù)顯示視圖

datepicker       Ext.DatePicker                              日期選擇面板

editor                Ext.Editor                                       編輯器

editorgrid         Ext.grid.EditorGridPanel              可編輯的表格

grid                   Ext.grid.GridPanel                         表格

paging              Ext.PagingToolbar                         工具欄中的間隔

panel                Ext.Panel                                        面板

progress          Ext.ProgressBar                            進度條

splitbutton        Ext.SplitButton                               可分裂的按鈕

tabpanel           Ext.TabPanel                                 選項面板

treepanel         Ext.tree.TreePanel                         樹

viewport           Ext.ViewPort                                  視圖

window             Ext.Window                                   窗口

工具欄組件:

toolbar              Ext.Toolbar                                    工具欄

tbbutton            Ext.Toolbar.Button                         按鈕

tbfill                   Ext.Toolbar.Fill                               文件

tbitem               Ext.Toolbar.Item                            工具條項目

tbseparator      Ext.Toolbar.Separator                  工具欄分隔符

tbspacer          Ext.Toolbar.Spacer                       工具欄空白

tbsplit               Ext.Toolbar.SplitButton                 工具欄分隔按鈕

tbtext                Ext.Toolbar.TextItem                     工具欄文本項

表單及字段組件:

form                  Ext.FormPanel Form                     面板

checkbox         Ext.form.Checkbox checkbox       錄入框

combo             Ext.form.ComboBox combo         選擇項

datefield          Ext.form.DateField                        日期選擇項

field                  Ext.form.Field                                 表單字段

fieldset            Ext.form.FieldSet                           表單字段組

hidden             Ext.form.Hidden                             表單隱藏域

htmleditor        Ext.form.HtmlEditor html               編輯器

numberfield     Ext.form.NumberField                   數(shù)字編輯器

radio                Ext.form.Radio                               單選按鈕

textarea           Ext.form.TextArea                          區(qū)域文本框

textfield            Ext.form.TextField                          表單文本框

timefield           Ext.form.TimeField                         時間錄入項

trigger              Ext.form.TriggerField                      觸發(fā)錄入項



Eric.Zhou 2009-11-20 09:04 發(fā)表評論
]]>
jquery 中對checkbox的一些操作http://www.tkk7.com/rain1102/archive/2009/06/05/280157.htmlEric.ZhouEric.ZhouFri, 05 Jun 2009 01:56:00 GMThttp://www.tkk7.com/rain1102/archive/2009/06/05/280157.htmlhttp://www.tkk7.com/rain1102/comments/280157.htmlhttp://www.tkk7.com/rain1102/archive/2009/06/05/280157.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/280157.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/280157.html $('#checkall').attr('checked', 'true');  選擇
$('#checkall').attr('checked', '');  不選

選擇多個checkbox:
$('#suppliersTable input[@type=checkbox]').trigger('click');

選擇所有選中的checkbox:
$('#suppliersTable input[@type=checkbox][@checked="true"]');

選擇所有未選中的checkbox
$('#suppliersTable input[@type=checkbox][@checked=""]');

觸發(fā)所有未選中的checkbox的onclick事件:
$('#suppliersTable input[@type=checkbox][@checked=""]').trigger('click');

計算所有選中的checkbox個數(shù):
$('#suppliersTable tbody input[@type=checkbox][@checked="true"]').length;

Eric.Zhou 2009-06-05 09:56 發(fā)表評論
]]>
Jmesa中加入checkbox列和導出功能http://www.tkk7.com/rain1102/archive/2009/06/04/280040.htmlEric.ZhouEric.ZhouThu, 04 Jun 2009 09:06:00 GMThttp://www.tkk7.com/rain1102/archive/2009/06/04/280040.htmlhttp://www.tkk7.com/rain1102/comments/280040.htmlhttp://www.tkk7.com/rain1102/archive/2009/06/04/280040.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/280040.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/280040.html加入checkbox的步驟如下:
需要在htmlRow標簽中加入 uniqueProperty屬性值, 并且修改tableFacade標簽為可編輯的
<jmesa:tableFacade
         id="suppliersTable"
         items="${suppliers}"
         maxRows="10"
         maxRowsIncrements="10,20,30"
         exportTypes="excel"
         editable="true"
         var="supplier">
          <jmesa:htmlTable width="100%" style="text-align:left;">
            <jmesa:htmlRow uniqueProperty="id">

然后修改checkbox的渲染列中的渲染器
<jmesa:htmlColumn property="flag" title="&nbsp;" filterable="false" sortable="false" worksheetEditor="org.jmesa.worksheet.editor.CheckboxWorksheetEditor"/>
這樣checkbox就可以使用了.
下面實現(xiàn)導出功能, 首先如上代碼, 需要設(shè)置 exportTypes="excel", 這里設(shè)置導出excel格式文件.
對應導出還需要增加一個onInvokeExportAction,
function onInvokeExportAction(id) {
       var parameterString = createParameterStringForLimit(id);
       window.open(path+'/supplier/export.do?' + parameterString);
}

下面來看看后來代碼如果處理被選擇的行:
@RequestMapping
 public void export(HttpServletRequest request, HttpServletResponse response) {
  WebContext webContext = new HttpServletRequestWebContext(request);
  WorksheetState state = new SessionWorksheetState("suppliersTable", webContext);
  Worksheet worksheet = state.retrieveWorksheet();
  Collection<WorksheetRow> rows = worksheet.getRows();

  List<Long> ids = new ArrayList<Long>();
  for (WorksheetRow row : rows) {
       ids .add(Long.parseLong(row.getUniqueProperty().getValue()));
  }
  List<Supplier> suppliers = new ArrayList<Supplier>();
  if (!ids.isEmpty()) {
   suppliers = cimssupplierService.getSuppliersByIds(ids);
  }
  ExcelUtil.writeSuppliers(response, suppliers);
 }
主要是綠色代碼如果獲取頁面上的一些信息.

Eric.Zhou 2009-06-04 17:06 發(fā)表評論
]]>
ajax請求時的緩存的問題[轉(zhuǎn)載]http://www.tkk7.com/rain1102/archive/2009/06/03/279756.htmlEric.ZhouEric.ZhouWed, 03 Jun 2009 02:33:00 GMThttp://www.tkk7.com/rain1102/archive/2009/06/03/279756.htmlhttp://www.tkk7.com/rain1102/comments/279756.htmlhttp://www.tkk7.com/rain1102/archive/2009/06/03/279756.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/279756.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/279756.htmlajax請求同一個url地址時,如果發(fā)現(xiàn)url地址沒有變而緩存里有就會直接去取值,不會再去請求服務(wù)器。這種情況會在不同的機器不同的IE上各有不同,解決的方式是在ajax請求的地址里加上一個隨機的參數(shù)例如(jQuery):

$.getJSON(path+"/library/structuresView.do?num=1&structCount="+customColumnNum*rowNum+"&datetime="+(new Date()).getTime(), "", function(json){alert(json)}) $.ajax({url: path+"/library/structuresPropertyPreview.do?fetch=all&random="+Math.random(), type: 'GET', success: function(data){alert(data)} });

只要ajax每次請求的地址不一樣就可以的。

原文地址:http://yaofeng911.javaeye.com/blog/379705


Eric.Zhou 2009-06-03 10:33 發(fā)表評論
]]>
防止jQuery Load使用緩存的方法[轉(zhuǎn)載]http://www.tkk7.com/rain1102/archive/2009/03/23/261505.htmlEric.ZhouEric.ZhouMon, 23 Mar 2009 05:50:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/23/261505.htmlhttp://www.tkk7.com/rain1102/comments/261505.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/23/261505.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/261505.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/261505.html緩存這東西,在一定程度上加快了頁面的裝載,但是也常常給我們帶來麻煩。我在上篇文章里簡單介紹了jQuery中Load方法的使用。在實際運用中,我們可能會碰到瀏覽器緩存的問題。比如我就在IE7里碰到這個問題。

jQuery Load樣本代碼:

$(document).ready(function(){
  $("#labels").load("/blog/categories/labels.html");
  //在頁面裝載時,在ID為#labels的DOM元素里插入labels.html的內(nèi)容。
});

當我更新了labels.html以后,在IE7里load方法仍舊在使用舊的labels.html,就算我按刷新鍵也不管用。好在jQuery提供一個防止ajax使用緩存的方法,把下面的語句加在head的javascript文件里,就可以解決問題。

$.ajaxSetup ({
    cache: false //關(guān)閉AJAX相應的緩存
});

此外我再介紹幾種方法解決緩存的方法。注意:我沒有在jQuery load的問題上測試過,這些方法僅供參考!

1.更改文件名,比如把labels.html改成lables_new.html,但是這是沒有辦法的辦法,一般沒有人這么做。

2.在labels.html后加上特定時間,比如lables.html?20081116。在實際工作中,在我更新css/javascript文件后,我都是用這種辦法來防止文件被緩存。

3.在labels.html文件的頂部加入以下聲明:

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

4.load函數(shù)不僅可以調(diào)用HTML,也可以調(diào)用script,比如labels.php,可以在php文件里使用header函數(shù):

<?php
Cache-Control: no-cache, must-revalidate");
?>


Eric.Zhou 2009-03-23 13:50 發(fā)表評論
]]>
Jmesa中處理Map的List對象http://www.tkk7.com/rain1102/archive/2009/03/19/260847.htmlEric.ZhouEric.ZhouThu, 19 Mar 2009 09:43:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/19/260847.htmlhttp://www.tkk7.com/rain1102/comments/260847.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/19/260847.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/260847.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/260847.html目前需求, 客戶上傳excel文件, 有列名, 列名不固定, 想預覽數(shù)據(jù), 使用Jmesa做table, 有兩種實現(xiàn)方法. 第一種使用動態(tài)類, 封裝map對象. 第二種是一種巧妙的方法. 下面先介紹第一種方法:
使用動態(tài)類:

package com.founder.cst.action;

import Java.util.ArrayList;
import Java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BasicDynaBean;
import org.apache.commons.beanutils.BasicDynaClass;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.DynaClass;
import org.apache.commons.beanutils.DynaProperty;
import org.jmesa.core.filter.MatcherKey;
import org.jmesa.facade.TableFacade;
import org.jmesa.facade.TableFacadeFactory;
import org.jmesa.view.html.component.HtmlTable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.founder.cst.common.StringFilterMatcher;

@Controller
@RequestMapping
public class DynaController {

 @RequestMapping
 public String books(final HttpServletRequest request, HttpServletResponse response, ModelMap model){

  DynaClass  bookClass = createBasicDynaClass();
  try {
   List<DynaBean> results = new ArrayList<DynaBean>();
   DynaBean book11 = bookClass.newInstance();
   book11.set("id", "1");
   book11.set("name", "Spring");
   book11.set("price", "18.29");
   results.add(book11);
   DynaBean book22 = bookClass.newInstance();
   book22.set("id", "2");
   book22.set("name", "Hibernate");
   book22.set("price", "12.29");
   results.add(book22);
   DynaBean book33 = bookClass.newInstance();
   book33.set("id", "3");
   book33.set("name", "Python");
   book33.set("price", "17.32");
   results.add(book33);
   
   TableFacade tableFacade = TableFacadeFactory.createTableFacade("booksTable", request);
   
   tableFacade.setColumnProperties("id", "name", "price");
   tableFacade.setMaxRows(10);
   tableFacade.setMaxRowsIncrements(10, 20, 30);
   tableFacade.setItems(results);
   HtmlTable table = (HtmlTable) tableFacade.getTable();
   table.getTableRenderer().setWidth("558px");
   table.getRow().setUniqueProperty("id");
   String html = tableFacade.render();
   model.addAttribute("html", html);
  } catch (IllegalAccessException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (InstantiationException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return "books";
 }
 
 public DynaClass createBasicDynaClass() {
  DynaClass dynaClass = null;
        //create basic field for dynaClass
        DynaProperty[] dynaProps = new DynaProperty[3];
        dynaProps[0] = new DynaProperty("id");
        dynaProps[1] = new DynaProperty("name", String.class);
        dynaProps[2] = new DynaProperty("price", String.class);
        //create map filed for dynaClass
        dynaClass = new BasicDynaClass("first", BasicDynaBean.class, dynaProps);
        return dynaClass;
    }


}

下面第二種:
@RequestMapping
 public String bookslist(final HttpServletRequest request, HttpServletResponse response, ModelMap model){
  List<Map<String, String>> books = new ArrayList<Map<String, String>>();
  Map<String, String> book1 = new HashMap<String, String>();
  book1.put("id", "1");
  book1.put("name", "Spring");
  book1.put("price", "18.29");
  books.add(book1);
  
  Map<String, String> book2 = new HashMap<String, String>();
  book2.put("id", "2");
  book2.put("name", "Hibernate");
  book2.put("price", "28.98");
  books.add(book2);
  
  Map<String, String> book3 = new HashMap<String, String>();
  book3.put("id", "3");
  book3.put("name", "Python");
  book3.put("price", "38.22");
  books.add(book3);
  
  model.addAttribute("books", books);
  return "booklist";
 }

頁面為:

<jmesa:tableFacade
     id="booksTable"
     items="${books}"
     maxRows="10"
     maxRowsIncrements="10,20,30"
     var="book">
     <jmesa:htmlTable width="630px">
      <jmesa:htmlRow>
       <c:forEach items="${book}" var="b">
       <jmesa:htmlColumn property="${b.key}" title="${b.key}" filterable="false"/>
       </c:forEach>
      </jmesa:htmlRow>
     </jmesa:htmlTable>
    </jmesa:tableFacade>

這里注意property中的值.

今天查看源碼, 和昨天想象一樣,  jmesa在渲染單元格的時候, 分兩種, 一種就是map類型, 使用get(key)來取值, 另一種就是普通的javabean對象, 使用getPropertyName()取值渲染.

/*
 * Copyright 2004 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jmesa.util;

import Java.util.Collection;
import Java.util.Map;

import org.apache.commons.beanutils.PropertyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * General utilities to process the Collecton of Beans or the Collection of
 * Maps. Most methods wrap or add value to the commons Beanutils.
 *
 * @since 2.1
 * @author Jeff Johnston
 */
public class ItemUtils {

    private static final Logger logger = LoggerFactory.getLogger(ItemUtils.class);
    public static final String JMESA_ITEM = "jmesa-item";

    private ItemUtils() {
        // hide constructor
    }

    /**
     * Get the value from the Bean or Map by property.
     *
     * @param item The Bean or Map.
     * @param property The Bean attribute or Map key.
     * @return The value from the Bean or Map.
     */
    public static Object getItemValue(Object item, String property) {
        Object itemValue = null;

        try {
            if (item instanceof Map) {
                itemValue = ((Map<?, ?>) item).get(property);
                if (itemValue != null) {
                    return itemValue;
                }

                // ports such as the tags will store the original bean
                Object bean = ((Map<?, ?>) item).get(JMESA_ITEM);
                if (bean == null) {
                    logger.debug("the map does not have property " + property);
                    return null;
                }

                itemValue = getItemValue(bean, property);
            } else {
                itemValue = PropertyUtils.getProperty(item, property);
            }
        } catch (Exception e) {
            logger.debug("item class " + item.getClass().getName() + " does not have property " + property);
        }

        return itemValue;
    }

    /**
     * Get the Class for the property.
     *
     * @param items The Collection of Beans or Maps.
     * @param property The Bean attribute or Map key.
     * @return The Class for the property.
     */
    public static Class<?> getPropertyClassType(Collection<?> items, String property)
        throws Exception {

        Object item = items.iterator().next();

        if (item instanceof Map) {
            for (Object object : items) {
                Map map = (Map) object;
                Object val = map.get(property);

                if (val == null) {
                    continue;
                }

                return val.getClass();
            }
        }

        return PropertyUtils.getPropertyType(item, property);
    }
}



Eric.Zhou 2009-03-19 17:43 發(fā)表評論
]]>
Jmesa中讓Toolbar和Statusbar在同一行http://www.tkk7.com/rain1102/archive/2009/03/17/260345.htmlEric.ZhouEric.ZhouTue, 17 Mar 2009 14:32:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/17/260345.htmlhttp://www.tkk7.com/rain1102/comments/260345.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/17/260345.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/260345.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/260345.htmlpackage com.founder.cst.common;

import Java.util.List;

import org.jmesa.view.ViewUtils;
import org.jmesa.view.component.Row;
import org.jmesa.view.html.HtmlBuilder;
import org.jmesa.view.html.HtmlSnippetsImpl;
import org.jmesa.view.html.component.HtmlTable;
import org.jmesa.view.html.toolbar.AbstractToolbar;
import org.jmesa.view.html.toolbar.MaxRowsItem;
import org.jmesa.view.html.toolbar.ToolbarItem;
import org.jmesa.view.html.toolbar.ToolbarItemType;

public class CustomToolbar extends AbstractToolbar {
 @Override
 public String render() {
  //addToolbarItem(ToolbarItemType.PAGE_NUMBER_ITEMS);
  addToolbarItem(ToolbarItemType.FIRST_PAGE_ITEM);
  addToolbarItem(ToolbarItemType.PREV_PAGE_ITEM);
  addToolbarItem(ToolbarItemType.NEXT_PAGE_ITEM);
  addToolbarItem(ToolbarItemType.LAST_PAGE_ITEM);
  addToolbarItem(ToolbarItemType.SEPARATOR);
  MaxRowsItem maxRowsItem = (MaxRowsItem) addToolbarItem(ToolbarItemType.MAX_ROWS_ITEM);
  if (getMaxRowsIncrements() != null) {
   maxRowsItem.setIncrements(getMaxRowsIncrements());
  }
  boolean exportable = ViewUtils.isExportable(getExportTypes());
  if (exportable) {
   addToolbarItem(ToolbarItemType.SEPARATOR);
   addExportToolbarItems(getExportTypes());
  }
  Row row = getTable().getRow();
  List columns = row.getColumns();
  boolean filterable = ViewUtils.isFilterable(columns);
  if (filterable) {
   addToolbarItem(ToolbarItemType.SEPARATOR);
   addToolbarItem(ToolbarItemType.FILTER_ITEM);
   addToolbarItem(ToolbarItemType.CLEAR_ITEM);
  }

  HtmlSnippetsImpl statusBar = new HtmlSnippetsImpl((HtmlTable)this.getTable(), this, this.getCoreContext());
  // super render
  HtmlBuilder html = new HtmlBuilder();

        html.table(2).border("0").cellpadding("0").cellspacing("1").close();
       
        html.tr(3).close();
        html.td(4).close();
        html.append(statusBar.statusBarText());
        html.tdEnd();
        for (ToolbarItem item : this.getToolbarItems()) {
            html.td(4).close();
            html.append(item.getToolbarItemRenderer().render());
            html.tdEnd();
        }

        html.trEnd(3);

        html.tableEnd(2);
        html.newline();
        html.tabs(2);

        return html.toString();
 }
}



Eric.Zhou 2009-03-17 22:32 發(fā)表評論
]]>
Jmesa- create a custom viewhttp://www.tkk7.com/rain1102/archive/2009/03/11/259123.htmlEric.ZhouEric.ZhouWed, 11 Mar 2009 07:15:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/11/259123.htmlhttp://www.tkk7.com/rain1102/comments/259123.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/11/259123.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/259123.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/259123.htmlIf you want to display a table without the pagination you need to set the max rows to the total rows, and then create a custom view to remove the toolbar. In addition, for this example, lets say that we also want to remove the statusbar? That makes sense as it will not offer any pagination information anyway.

First we need to set the max rows to the total amount of items that we want to display.

tableFacade.setMaxRows(items.size());

Then we need to implement a custom view. If you compare this view to the HtmlView in the API you can see that I just removed two lines of code. One to remove the toolbar and one for the status bar.

public class CustomView  extends AbstractHtmlView {
   
public Object render() {
       
HtmlSnippets snippets = getHtmlSnippets();

       
HtmlBuilder html = new HtmlBuilder();

        html
.append(snippets.themeStart());

        html
.append(snippets.tableStart());

        html
.append(snippets.theadStart());

        html
.append(snippets.filter());

        html
.append(snippets.header());

        html
.append(snippets.theadEnd());

        html
.append(snippets.tbodyStart());

        html
.append(snippets.body());

        html
.append(snippets.tbodyEnd());

        html
.append(snippets.footer());

        html
.append(snippets.tableEnd());

        html
.append(snippets.themeEnd());

        html
.append(snippets.initJavascriptLimit());

       
return html.toString();
   
}
}

Lastly, just plug your custom view into the TableFacade.

API

tableFacade.setView(new CustomView());

Tags

<jmesa:tableFacade view="com.mycompany.CustomView">


Eric.Zhou 2009-03-11 15:15 發(fā)表評論
]]>
Jmesa中的Limit使用http://www.tkk7.com/rain1102/archive/2009/03/06/258296.htmlEric.ZhouEric.ZhouFri, 06 Mar 2009 13:39:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/06/258296.htmlhttp://www.tkk7.com/rain1102/comments/258296.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/06/258296.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/258296.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/258296.html  TableFacade tableFacade = TableFacadeFactory.createTableFacade("structuresTable", request);
  tableFacade.setColumnProperties("chkbox", "id", "formula", "molTable.molName", "molTable.cas", "mdlNumber", "molWeight");
  tableFacade.setEditable(true);
  tableFacade.setMaxRows(10);
  tableFacade.setMaxRowsIncrements(10, 20, 30);
  
  tableFacade.setTotalRows(cd_ids.size());
  
  Limit limit = tableFacade.getLimit();
  int rowStart = limit.getRowSelect().getRowStart();
  int rowEnd = limit.getRowSelect().getRowEnd();
  
  List<Long> curResultIds = cd_ids.subList(rowStart, rowEnd);
  
  List<ACD1Structure> curStructures   = structureService.getACD1StructuresByIds(curResultIds);
  
  tableFacade.setItems(curStructures);
  
  HtmlTable table = (HtmlTable) tableFacade.getTable();
  table.getTableRenderer().setWidth("1000px");
  table.getRow().setUniqueProperty("id");
  
  HtmlColumn smilesColumn = table.getRow().getColumn("id");
  smilesColumn.setEditable(false);
  smilesColumn.setTitle(messageSource.getMessage("chemical.structure.title", null, request.getLocale()));
  
  HtmlColumn formulaColumn = table.getRow().getColumn("formula");
  formulaColumn.setEditable(false);
  formulaColumn.setTitle(messageSource.getMessage("chemical.formula.title", null, request.getLocale()));
  
  HtmlColumn molNameColumn = table.getRow().getColumn("molTable.molName");
  molNameColumn.setEditable(false);
  molNameColumn.setTitle(messageSource.getMessage("chemical.name.title", null, request.getLocale()));
  
  HtmlColumn casColumn = table.getRow().getColumn("molTable.cas");
  casColumn.setEditable(false);
  casColumn.setTitle(messageSource.getMessage("chemical.cas.title", null, request.getLocale()));
  
  HtmlColumn mdlNumberColumn = table.getRow().getColumn("mdlNumber");
  mdlNumberColumn.setEditable(false);
  mdlNumberColumn.setTitle(messageSource.getMessage("chemical.mdl.title", null, request.getLocale()));
  
  HtmlColumn molWeightColumn = table.getRow().getColumn("molWeight");
  molWeightColumn.setEditable(false);
  molWeightColumn.setTitle(messageSource.getMessage("chemical.mw.title", null, request.getLocale()));
  
  //for smiles column
  
  smilesColumn.setFilterable(false);
  smilesColumn.setSortable(false);
  smilesColumn.getCellRenderer().setCellEditor(new CellEditor() {
            public Object getValue(Object item, String property, int rowcount) {
                Object value = new BasicCellEditor().getValue(item, property, rowcount);
                String bgcolor = (rowcount % 2 == 0) ? "e3e3e3" : "ffffff";
                HtmlBuilder html = new HtmlBuilder();
                html.append("<img class=\"hand\" width=\"140\" onclick=\"supplierInfo('"+value+"')\" src=\""+request.getContextPath()+"/compoundsearch/showAsImage.do?id="+value+"&bgcolor="+bgcolor+"\">");
                html.aEnd();
                return html.toString();
            }
        });

  //for checkbox column
  HtmlColumn chkbox = table.getRow().getColumn("chkbox");
  chkbox.getCellRenderer().setWorksheetEditor(new CheckboxWorksheetEditor());
  chkbox.setTitle("&nbsp;");
  chkbox.setFilterable(false);
  chkbox.setSortable(false);
  
  //render
  String html = tableFacade.render();



Eric.Zhou 2009-03-06 21:39 發(fā)表評論
]]>
Jmesa2.4.1小例子http://www.tkk7.com/rain1102/archive/2009/03/04/257888.htmlEric.ZhouEric.ZhouWed, 04 Mar 2009 14:21:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/04/257888.htmlhttp://www.tkk7.com/rain1102/comments/257888.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/04/257888.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/257888.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/257888.html List<Structure> structures = structureService.getAllStructures();

在JSP頁面中代碼為:
<%@ page language="Java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/jmesa.tld" prefix="jmesa"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html>
 <head>
  <title><spring:message code="chemical.cst" />
  </title>
  <link href="${pageContext.request.contextPath}/css/jmesa.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/common/jquery-1.2.6.js"></script>
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/jmesa.js"></script>
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.jmesa.js"></script>
  <script type="text/javascript">
      function onInvokeAction(id) {   
       createHiddenInputFieldsForLimitAndSubmit(id);
      }
  </script>
 </head>
 <body>
  <form action="${pageContext.request.contextPath}/cst/structures.do" method="post">
   <div id="structuresTablePlaceholder">
    <jmesa:tableFacade
     id="structuresTable"
     items="${structures}"
     maxRows="10"
     maxRowsIncrements="10,20,30"
     var="structrue">
     <jmesa:htmlTable width="630px">
      <jmesa:htmlRow>
       <jmesa:htmlColumn property="smiles" title="Smiles" filterable="false"/>
       <jmesa:htmlColumn property="formula" title="Formula" filterable="false"/>
       <jmesa:htmlColumn property="mdlNumber" title="MDL" filterable="false"/>
       <jmesa:htmlColumn property="molWeight" title="MW" filterable="false"/>
      </jmesa:htmlRow>
     </jmesa:htmlTable>
    </jmesa:tableFacade>
   </div>
  </form>
 </body>
</html>


Eric.Zhou 2009-03-04 22:21 發(fā)表評論
]]>
jQuery中一些不常用的方法屬性【轉(zhuǎn)載】http://www.tkk7.com/rain1102/archive/2009/03/03/257656.htmlEric.ZhouEric.ZhouTue, 03 Mar 2009 13:24:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/03/257656.htmlhttp://www.tkk7.com/rain1102/comments/257656.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/03/257656.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/257656.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/257656.htmlindex(subject)

搜索與參數(shù)表示的對象匹配的元素,并返回相應元素的索引值。如果找到了匹配的元素,從0開始返回;如果沒有找到匹配的元素,返回-1。

data()

data(elem):為頁面對象添加唯一標識。

data(name, value):將數(shù)據(jù)保存在元素的一個key里面。$("#box").data("shape","rectangle")。

data(name):獲取值。$("#box").data("shape") //"rectangle"。

removeData(name):刪除通過data()方法賦予的值。$("#box").removeData("shape")。

attr(key,fn)

為所有匹配的元素設(shè)置一個計算的屬性值。不提供值,而是提供一個函數(shù),由這個函數(shù)計算的值作為屬性值。

hasClass(class)

檢查當前的元素是否含有某個特定的類,如果有,則返回true。這其實就是is("." + class)。

val(val)

設(shè)置每一個匹配元素的值。在 jQuery 1.2, 這也可以為select元件賦值。參數(shù)val(String)要設(shè)置的值。

check,select,radio等都能使用為之賦值。參數(shù)val(Array<String>)用于 check/select 的值。

slice(start,[end])

選取一個匹配的子集。

add(expr)

把與表達式匹配的元素添加到j(luò)Query對象中。這個函數(shù)可以用于連接分別與兩個表達式匹配的元素結(jié)果集。

參數(shù)expr(String, DOMElement, Array<DOMElement>)用于匹配元素并添加的表達式字符串,或者用于動態(tài)生成的HTML代碼,如果是一個字符串數(shù)組則返回多個元素。

nextAll([expr])

查找當前元素之后的所有元素。

prev([expr])

取得一個包含匹配的元素集合中每一個元素緊鄰的前一個同輩元素的元素集合。

prevAll([expr])

查找當前元素之前所有的同輩元素。

andSelf()

將先前所選的加入當前元素中。

replaceWith(content)

將所有匹配的元素替換成指定的HTML或DOM元素。參數(shù)content(String, Element, jQuery):用于將匹配元素替換掉的內(nèi)容。

replaceAll(selector)

用匹配的元素替換掉所有 selector匹配到的元素。參數(shù)selector(選擇器)用于查找所要被替換的元素。

clone([true])

克隆匹配的DOM元素并且選中這些克隆的副本。設(shè)置參數(shù)[true]是對象的所有事件處理一并克隆。

offset()

獲取匹配元素在當前視口的相對偏移。返回的對象包含兩個整形屬性:top 和 left。此方法只對可見元素有效。

返回Object{top,left}。

one(type,[data],fn)

為每一個匹配元素的特定事件(像click)綁定一個一次性的事件處理函數(shù)。

在每個對象上,這個事件處理函數(shù)只會被執(zhí)行一次。其他規(guī)則與bind()函數(shù)相同。這個事件處理函數(shù)會接收到一個事件對象,可以通過它來阻止(瀏覽器)默認的行為。如果既想取消默認的行為,又想阻止事件起泡,這個事件處理函數(shù)必須返回false。

toggle(fn,fn2,[fn3,fn4,...])

每次點擊時切換要調(diào)用的函數(shù)。函數(shù)數(shù)目可以是多個。

stop()

停止所有在指定元素上正在運行的動畫。如果隊列中有等待執(zhí)行的動畫,他們將被馬上執(zhí)行。

queue([callback/queue])

queue:返回指向第一個匹配元素的隊列(將是一個函數(shù)數(shù)組。

queue(callback):在匹配的元素的動畫隊列中添加一個函數(shù)。

queue(queue):將匹配元素的動畫隊列用新的一個隊列來代替(函數(shù)數(shù)組)。

dequeue()

從動畫隊列中移除一個隊列函數(shù)。

jQuery.browser.version

瀏覽器渲染引擎版本號。

jQuery.boxModel

當前頁面中瀏覽器是否使用標準盒模型渲染頁面。

PS:以前很少用這些方法屬性,很多還不知道。這跟中文CHM版jQuery API不無關(guān)系,那本廣為流傳的中文版手冊已經(jīng)過時,建議直接閱讀官方文檔



Eric.Zhou 2009-03-03 21:24 發(fā)表評論
]]>
連動出發(fā)事件在jQuery中是如此簡單與優(yōu)美http://www.tkk7.com/rain1102/archive/2009/03/03/257654.htmlEric.ZhouEric.ZhouTue, 03 Mar 2009 13:15:00 GMThttp://www.tkk7.com/rain1102/archive/2009/03/03/257654.htmlhttp://www.tkk7.com/rain1102/comments/257654.htmlhttp://www.tkk7.com/rain1102/archive/2009/03/03/257654.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/257654.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/257654.html當頁面加載完需要對一些數(shù)據(jù)進行操作時候,我這里當取完供應商列表,需要默認選擇第一個供應商,然后再去第一個供應商相關(guān)信息。
if ($('#suppliertable').find('tr:eq(0)') != undefined) {
   $('#suppliertable').find('tr:eq(0)').trigger('click');
 }

上面為table格式形式的列表。但如果為select元素呢,比如做級聯(lián)下拉菜單則可以這樣寫:
if ($('#chemical_regn').get(0) != undefined) {
    $('#chemical_regn').get(0).options[0].selected = true;    // $('#chemical_regn').[0].selectedIndex = 0;
   $('#chemical_regn').trigger('click');
 }


Eric.Zhou 2009-03-03 21:15 發(fā)表評論
]]>
jQuery基礎(chǔ)教程筆記http://www.tkk7.com/rain1102/archive/2009/02/14/254694.htmlEric.ZhouEric.ZhouSat, 14 Feb 2009 12:25:00 GMThttp://www.tkk7.com/rain1102/archive/2009/02/14/254694.htmlhttp://www.tkk7.com/rain1102/comments/254694.htmlhttp://www.tkk7.com/rain1102/archive/2009/02/14/254694.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/254694.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/254694.html第一章:入門

$()取得頁面中的元素

$(document).ready(function(){
 $('.poem-stanza').addClass('emphasized');
});

說明:

$('.poem-stanza')       //取得頁面中添加了類poem-stanza的元素
.addClass('emphasized');   //添加Css樣式,emphasized為類樣式
.removeClass();
 
第二章:選擇符

$(document).ready(function(){
 //CSS選擇符
 $('#selectedplays>li').addClass('horizontal');          //查找id為selectedplays元素的頂層子元素li,添加樣式
 $('#selectedplays>li:not(.horizotal)').addClass('sublevel');    //查找id為selectedplays元素的頂層子元素li,并且沒有類horizotal 

 //XPath選擇符
 $('a[@href^="mailto:"]').addClass('mailto');           //查找錨元素中屬性href以“mailto:”開頭的元素
 $('a[@href$=".pdf"]').addClass('pdflink');            //查找錨元素中屬性href以“.pdf”結(jié)尾的元素
 $('a[@href*="mysite.com"]').addClass('mysite');        //查找錨元素中屬性href中包含“mysite.com”的元素(任意位置)

 //自定義選擇符
 $('tr:odd').addClass('odd');                   //查找奇數(shù)行
 $('tr:even').addClass('even');                  //查找偶數(shù)行
 //注::odd()和:even()選擇符使用的都是Javascript本身的從0開始得編號方式。表格的第1行編號為0(偶數(shù)),而第2行編號為1(奇數(shù))
 $('td:contains("Henry")').addClass('highlight');                   //查找td中包含"Henry"的

 //DOM遍歷方法
 $('th').parent().addClass('tableheading');           //查找th的父元素即標題行
 $('tr:not([th]):even').addClass('even');              //查找tr元素中不包含子為th的,并且是偶數(shù)行
 $('tr:not([th]):odd').addClass('odd');          
 $('td:contains("Henry")').next().addClass('highlight');         //查找td中包含“Henry”的單元格的下一個單元格
 $('td:contains("Comedy")').siblings().addClass('highlight');  //查找td中包含“Comedy”的同級單元格
 $('td:contains("Comedy")').parent().find('td:gt(0)').addClass('highlight');
 //查找td中包含“Comedy”的父,再去查找td單元格編號大于0的單元格
 $('td:contains("Comedy)').parent().find('td').not(':contains("Comedy")').addClass('highlight');
 //查找td中包含“Comedy”的父,再去查找td單元格不包含“Comedy”的單元格

 //訪問DOM元素
 var tag = $('#myelement').get(0).tagName;
});


第三章:事件――扣動扳機

綁定事件:

  .bind(‘click’,function(){})
  $(‘#switcher-large’).bind(‘click’,function(){…});給id為switcher-large的元素綁定click事件

  可簡寫為
  $(‘#switcher-large’).click(function(){…});

  方法:
  .toggle(function(){},function(){})

接受兩個參數(shù)(都是函數(shù))第一次點擊調(diào)用第一個函數(shù),第二次點擊調(diào)用第二個
$(‘#switcher h3’).toggle(function(){
       $(‘#switcher .button’).addClass(‘hidden’);

},function(){
       $(‘#switcher .button’).removeClass(‘hidden’);

});

.toggleClass()是一種跟優(yōu)雅得方案,但對于交替執(zhí)行的操作而言,.toggle()的適用性更強

$(‘#switcher h3’).click(function(){
       $(‘#switcher .button’).toggleClass(‘hidden’); //自動檢查該類是否存在
});

  .hover(function(){},function(){})

接受兩個函數(shù)參數(shù),第一個指針進入,第二個指針離開

$(‘#switcher .button’).hover(function(){
       $(this).addClass(‘hover’);
},function(){
       $(this).removeClass(‘hover’);
});

  .unbind(‘click’)

移除事件
  .trigger(‘click’)

模擬用戶操作
$(‘#switcher’).trigger(‘click’); 模擬點擊了一次switcher

第四章:效果――為操作添加藝術(shù)性

1.修改內(nèi)聯(lián)CSS

語法:
.css(‘property’,’value’);
.css(‘property’:’value’,’property’:’value’);

用法:
var currentSize = $(‘div.speech’).css(‘fontSize’);//得到div.speech得字體大小
var num = parasFloat(currentSize,10);  //將currentSize轉(zhuǎn)換為Float型
var unit = currentSize.slice(-2); //返回從指定的字符開始的一個子字符串,-2為倒數(shù)第二個
num *= 1.5;
$(‘div.speech’).css(‘fontSize’,num+unit); //設(shè)置樣式

2.基本的顯示和隱藏

.show();
.hide();

用法:
$(‘p:eq(1)’).hide(); //將第二個段落隱藏

3.效果和速度
指定顯示速度
3種:slow、normal和fast 時間:0.6、0,4、0.2。也可以指定.show(850)
$(‘p:eq(2)’).show(‘slow’);

淡入和淡出

.fadeIn();        //淡出
.fadeOut();   //淡出

$(‘p:eq(2)’).fadeIn(‘slow’);

4.多重效果

語句:.animate({param1:’value1’,parame2:’value2’},speed,function(){回調(diào)});

用法:$(‘p:eq(1)’).animate({height:’show’,width:’show’,opacity:’show’},’slow’);

這里使用簡寫的show將高度、寬度回復到被隱藏之前的值

5.并發(fā)與排隊效果
處理一組元素
$(‘div.buttont’).animate({left:650},’slow’).animate({height:38},’slow’);
先移動到left為650的位置,在將高度設(shè)置為38
$(‘div.button’)
       .fadeTo(‘slow’,0.5)                            //先淡化
       .animate({left:650},’slow’)           //在移動
       .fadeTo(‘slow’,1.0)                            //在淡出
       .slideUp(‘slow’)                          //最后滑到上方隱藏

注意:排隊不適用于其他的非效果方法,例如:.css()
處理多組元素

$(‘p:eq(2)’).slideUp(‘slow’).next().slideDown(‘slow’); 段落3向上滑出,同時段落4向下滑入

回調(diào)函數(shù):

Var $thisPara = $(‘p:eq(2)’);
$(‘p:eq(2)’).next().slideDown(‘slow’,function(){

       $thisPara.slideUp(‘slow’);

});

段落4下滑完成后,段落3才開始上滑

第五章:DOM操作-基于命令改變頁面

1.操作屬性
非css屬性

$(document).ready(function(){
    $('div.chapter a[@href*=wikipedia]').each(function(index){
        var $thisLink = $(this);
        $thisLink.attr({
            'rel': 'external',
            'id': 'wikilink-' + index,
            'title': 'learn more about ' + $thisLink.text() + ' at wikipedia'
        });
    });
});

//遍歷div.chapter 下面所以錨元素href中包含wikipedia,為其添加屬性
深入理解$()工廠函數(shù)
$('<a href="#top">back to top</a>');    創(chuàng)建新元素

2.插入新元素

.insertBefore()
.before()

作用相同,區(qū)別取決于將它們與其他方法進行連綴

.insertAfter()
.after()

// $('div.chapter p').after('<a href="#top">back to top</a>');

// $('div.chapter p').before('<a href="#top">back to top</a>');

$('<a href="#aaa">back to top</a>').insertAfter('div.chapter p');

$('<a id="aaa" name="top"></a>').prependTo('body');

.perpendTo插入了作為目標的錨

// $('<a href="#top">back to top</a>').insertBefore('div.chapter p');

3.移動元素

$('span.footnote').insertBefore('#footer');
將span中類為footnote的插入到id為footer的前面
標注、編號和鏈接到上下文
    $('span.footnote').each(function(index){
        $(this)
            .before('<a href="#foot-note-' + (index+1) +
                    '" id="context-' + (index+1) +
                    '" class="context"><sup>' + (index+1) +
                    '</sup></a>');
    });
$('span.footnote').insertBefore('#footer');

遍歷span.footnote,在各個元素前加標注后,在將span.footnote添加到#footer前

插入腳注

$('<ol id="notes"></ol>').insertAfter('div.chapter');
$('span.footnote').each(function(index){
        $(this)
            .before('<a href="#foot-note-' + (index+1) +
                    '" id="context-' + (index+1) +
                    '" class="context"><sup>' + (index+1) +
                    '</sup></a>')
            .appendTo('#notes')
            .append('&nbsp;(<a href="#context-'+(index+1)+'">context</a>)');   
});

先創(chuàng)建一個ol元素notes,并添加到div.chapter后面,遍歷span.footnote,先添加標注,然后通過appendTo其添加到ol末尾,最后又通過append添加一個錨元素。

4.包裝元素

.wrap()
.wrap('<li id="foot-note-' + (index+1) + '"></li>')

5.復制元素

.clone()

$('div.chapter p:eq(0)').clone().insertBefore('div.chapter');

將div.chapter中得第一段復制后插入在div.chapter前面

深度復制

$('div.chapter p:eq(0)').clone(false)

只復制結(jié)構(gòu),內(nèi)部的文本沒有復制過來,因為文本也是DOM節(jié)點

通過復制創(chuàng)建突出引用

var $parentParagraph = $(this).parent('p');

$parentParagraph.css('position','relative');

$(this).clone()

.addClass('pulled')

.prependTo($parentParagraph);

修飾突出引用

$clonedCopy.addClass('pulled')
.find('span.drop')
    .html('&hellip;')
    .end()
    .prependTo($parentParagraph)
    .wrap('<div class="pulled-wrapper"></div>');

var clonedText = $clonedCopy.text();

$clonedCopy.html(clonedText);

第六章:AJAX 讓網(wǎng)站與時俱進

1.基于請求加載數(shù)據(jù)
追加HTML

//載入遠程 HTML 文件代碼并插入至 DOM 中

$('#dictionary').load('a.html',function(){
      Alert(“加載完畢!”);//回調(diào)函數(shù)
})

操作JavaScript對象

JSON:
[
{
    "term": "BACKBITE",
    "part": "v.t.",
    "definition": "To speak of a man as you find him when he can't find you."
  },
  {
    "term": "BEARD",
    "part": "n.",
    "definition": "The hair that is commonly cut off by those who justly execrate the absurd Chinese custom of shaving the head."
  }
]

JQuery:

$.getJSON('b.json',function(data){ //通過 HTTP GET 請求載入 JSON 數(shù)據(jù)
            $.each(data,function(entryIndex,entry){
                var html = '<div class="entry">';
                html += '<h3 class="term">' + entry['term'] + '</h3>';
                html += '<div class="pare">' + entry['part'] + '</div>';
                html += '<div class="definition">';
                html += entry['definition'];
                if(entry['quote']){
                    html += '<div class="quote">';
                    $.each(entry['quote'],function(lineIndex,line){
                        html += '<div class="quote-line">' + line + '</div>';
                    });
                    if(entry['author']){
                        html += '<div class="quote-author">' + entry['author'] + '</div>';
                    }
                    html += '</div>';
                }
                html += '</div>';
                html += '</div>';
            });

執(zhí)行腳本

通過 HTTP GET 請求載入并執(zhí)行一個 JavaScript 文件

$.getScript('c.js',function(){
    Alert(“加載完畢”);//回調(diào)函數(shù)
});

加載XML文檔

//通過遠程 HTTP GET 請求載入信息。

$.get('d.xml',function(data){
        $(data).find('entry').each(function(){
                var $entry = $(this);
                var html = '<div class="entry">';
                html += '<h3 class="term">' + $entry.attr('term') + '</h3>';
                html += '<div class="part">' + $entry.attr('part') + '</div>';
                html += '<div class="definition">'
                html += $entry.find('definition').text();
                var $quote = $entry.find('quote');
                if($quote.length){
                    html += '<div class="quote">';
                    $quote.find('line').each(function(){
                        html += '<div class="quote-line">' + $(this).text() + '</div>';                    
                    });
                    if($quote.attr('author')){
                        html += '<div class="quote-author">' + $quote.attr('author') + '</div>';
                    }
                    html += '</div>';
                }
                html += '</div>';
                html += '</div>';
                $('#dictionary').append($(html));
            });
        });

2.選擇數(shù)據(jù)格式

3.向服務(wù)器傳遞數(shù)據(jù)

4.關(guān)注請求

方法:

.ajaxStart()
.ajaxStop()

當AJAX請求開始且尚未進行其他傳輸時,會觸發(fā).ajaxStart()的回調(diào)函數(shù),相反,當最后一次活動請求終止時,則會執(zhí)行通過.ajaxStop()注冊的回調(diào)函數(shù)。

示例:  

//當請求時,顯示#loading,結(jié)束時,隱藏loading

$(document).ready(function(){
$('#loading').ajaxStart(function(){
     $(this).show();
}).ajaxStop(function(){
     $(this).hide();
});
});

5.Ajax和事件

限制函數(shù)綁定的作用域

$(document).ready(function(){
var bindBehaviors = function(scope){
     $('h3',scope).click(function(){
         $(this).toggleClass('highlighted');
     });
}; 

bindBehaviors(this);

//這里的綁定作用域是document

$(document).ready(function(){
     $('#letter-a .button').click(function(){
         $('#dictionary').hide().load('a.html',function(){
             bindBehaviors(this);
//這里的是文檔中的所以<h3>元素
             $(this).fadeIn();
         });
     });
});

});

6.安全限制

 



Eric.Zhou 2009-02-14 20:25 發(fā)表評論
]]>
強烈推薦:240多個jQuery插件 http://www.tkk7.com/rain1102/archive/2009/02/12/254451.htmlEric.ZhouEric.ZhouThu, 12 Feb 2009 13:39:00 GMThttp://www.tkk7.com/rain1102/archive/2009/02/12/254451.htmlhttp://www.tkk7.com/rain1102/comments/254451.htmlhttp://www.tkk7.com/rain1102/archive/2009/02/12/254451.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/254451.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/254451.html

jqueryjQuery is definitely my favourite Javascript Library and this ultimate jQuery Plugin List is for all other jQuery Lovers out there. At the moment there are about 240+ awesome Plugins in the List I’m sure that there are a lot of other plugins out there - so if you knew one that’s not in the list please post a comment and i will add it. Thanks!

File upload

Ajax File Upload
jQUploader
Multiple File Upload plugin
jQuery File Style
Styling an input type file
Progress Bar Plugin

Form Validation

jQuery Validation
Auto Help
Simple jQuery form validation
jQuery XAV - form validations
jQuery AlphaNumeric
Masked Input
TypeWatch Plugin
Text limiter for form fields
Ajax Username Check with jQuery

Form - Select Box stuff

jQuery Combobox
jQuery controlled dependent (or Cascadign) Select List
Multiple Selects
Select box manipulation
Select Combo Plugin
jQuery - LinkedSelect
Auto-populate multiple select boxes
Choose Plugin (Select Replacement)

Form Basics, Input Fields, Checkboxes etc.

jQuery Form Plugin
jQuery-Form
jLook Nice Forms
jNice
Ping Plugin
Toggle Form Text
ToggleVal
jQuery Field Plugin
jQuery Form’n Field plugin
jQuery Checkbox manipulation
jTagging
jQuery labelcheck
Overlabel
3 state radio buttons
ShiftCheckbox jQuery Plugin
Watermark Input
jQuery Checkbox (checkboxes with imags)
jQuery SpinButton Control
jQuery Ajax Form Builder
jQuery Focus Fields
jQuery Time Entry

Time, Date and Color Picker

jQuery UI Datepicker
jQuery date picker plugin
jQuery Time Picker
Time Picker
ClickPick
TimePicker
Farbtastic jQuery Color Picker Plugin
Color Picker by intelliance.fr

Rating Plugins

jQuery Star Rating Plugin
jQuery Star Rater
Content rater with asp.net, ajax and jQuery
Half-Star Rating Plugin

Search Plugins

Autocomplete Box
jQuery Suggest
jQuery Autocomplete
jQuery Autocomplete Mod
jQuery Autocomplete by AjaxDaddy
jQuery Autocomplete Plugin with HTML formatting
jQuery Autocompleter
AutoCompleter (Tutorial with PHP&MySQL)
quick Search jQuery Plugin

Inline Edit & Editors

jTagEditor
WYMeditor
jQuery jFrame
Jeditable - edit in place plugin for jQuery
jQuery editable
jQuery Disable Text Select Plugin
Edit in Place with Ajax using jQuery
jQuery Plugin - Another In-Place Editor
TableEditor
tEditable - in place table editing for jQuery

Audio, Video, Flash, SVG, etc

jMedia - accessible multi-media embedding
JBEdit - Ajax online Video Editor
jQuery MP3 Plugin
jQuery Media Plugin
jQuery Flash Plugin
Embed QuickTime
SVG Integration
jQuery Multimedia Portfolio
jQuery YouTube Plugin

Photos/Images/Galleries

ThickBox
jQuery lightBox plugin
jQuery FancyBox
jQuery Multimedia Portfolio
jQuery Image Strip
jQuery slideViewer
jQuery jqGalScroll 2.0
jQuery - jqGalViewII
jQuery - jqGalViewIII
jQuery Photo Slider
jQuery Thumbs - easily create thumbnails
jQuery jQIR Image Replacement
jCarousel Lite
jQPanView
jCarousel
Interface Imagebox
Image Gallery using jQuery, Interface & Reflactions
simple jQuery Gallery
jQuery Gallery Module
EO Gallery
jQuery ScrollShow
jQuery Cycle Plugin
jQuery Flickr
jQuery Lazy Load Images Plugin
Zoomi - Zoomable Thumbnails
jQuery Crop - crop any image on the fly
Image Reflection

Google Map

jQuery Plugin googlemaps
jMaps jQuery Maps Framework
jQmaps
jQuery & Google Maps
jQuery Maps Interface forr Google and Yahoo maps
jQuery J Maps - by Tane Piper

Games

Tetris with jQuery
jQuery Chess
Mad Libs Word Game
jQuery Puzzle
jQuery Solar System (not a game but awesome jQuery Stuff)
jQuery Memory

Tables, Grids etc.

UI/Tablesorter
jQuery ingrid
jQuery Grid Plugin
Table Filter - awesome!
TableEditor
jQuery Tree Tables
Expandable “Detail” Table Rows
Sortable Table ColdFusion Costum Tag with jQuery UI
jQuery Bubble
TableSorter
Scrollable HTML Table
jQuery column Manager Plugin
jQuery tableHover Plugin
jQuery columnHover Plugin
jQuery Grid
TableSorter plugin for jQuery
tEditable - in place table editing for jQuery
jQuery charToTable Plugin
jQuery Grid Column Sizing
jQuery Grid Row Sizing

Charts, Presentation etc.

Flot
jQuery Wizard Plugin
jQuery Chart Plugin
Bar Chart
Accessible Charts using Canvas and jQuery

Border, Corners, Background

jQuery Corner
jQuery Curvy Corner
Nifty jQuery Corner
Transparent Corners
jQuery Corner Gallery
Gradient Plugin

Text and Links

jQuery Spoiler plugin
Text Highlighting
Disable Text Select Plugin
jQuery Newsticker
Auto line-height Plugin
Textgrad - a text gradient plugin
LinkLook - a link thumbnail preview
pager jQuery Plugin
shortKeys jQuery Plugin
jQuery Biggerlink
jQuery Ajax Link Checker
Chili jQuery code highlighter plugin
jScroller

Tooltips

jQuery Plugin - Tooltip
jTip - The jQuery Tool Tip
clueTip
BetterTip
Flash Tooltips using jQuery
ToolTip

Menus, Navigations

jQuery Tabs Plugin - awesome! [demo nested tabs]
another jQuery nested Tab Set example (based on jQuery Tabs Plugin)
jQuery idTabs
jdMenu - Hierarchical Menu Plugin for jQuery
jQuery SuckerFish Style
jQuery Plugin Treeview
treeView Basic
FastFind Menu
Sliding Menu
Lava Lamp jQuery Menu
jQuery iconDock
jVariations Control Panel
ContextMenu plugin
clickMenu
CSS Dock Menu
jQuery Pop-up Menu Tutorial
Sliding Menu

Accordions, Slide and Toggle stuff

jQuery Plugin Accordion
jQuery Accordion Plugin Horizontal Way
haccordion - a simple horizontal accordion plugin for jQuery
Horizontal Accordion by portalzine.de
HoverAccordion
Accordion Example from fmarcia.info
jQuery Accordion Example
jQuery Demo - Expandable Sidebar Menu
Sliding Panels for jQuery
jQuery ToggleElements
Coda Slider
jCarousel
Accesible News Slider Plugin
Showing and Hiding code Examples
jQuery Easing Plugin
jQuery Portlets
AutoScroll
Innerfade
CodaSlider

Drag and Drop

UI/Draggables
EasyDrag jQuery Plugin
jQuery Portlets
jqDnR - drag, drop resize
Drag Demos

XML XSL JSON Feeds

XSLT Plugin
jQuery Ajax call and result XML parsing
xmlObjectifier - Converts XML DOM to JSON
jQuery XSL Transform
jQuery Taconite - multiple Dom updates
RSS/ATOM Feed Parser Plugin
jQuery Google Feed Plugin

Browserstuff

Wresize - IE Resize event Fix Plugin
jQuery ifixpng
jQuery pngFix
Link Scrubber - removes the dotted line onfocus from links
jQuery Perciformes - the entire suckerfish familly under one roof
Background Iframe
QinIE - for proper display of Q tags in IE
jQuery Accessibility Plugin
jQuery MouseWheel Plugin

Alert, Prompt, Confirm Windows

jQuery Impromptu
jQuery Confirm Plugin
jqModal
SimpleModal

CSS

jQuery Style Switcher
JSS - Javascript StyleSheets
jQuery Rule - creation/manipulation of CSS Rules
jPrintArea

DOM, Ajax and other jQuery plugins

FlyDOM
jQuery Dimenion Plugin
jQuery Loggin
Metadata - extract metadata from classes, attributes, elements
Super-tiny Client-Side Include Javascript jQuery Plugin
Undo Made Easy with Ajax
JHeartbeat - periodically poll the server
Lazy Load Plugin
Live Query
jQuery Timers
jQuery Share it - display social bookmarking icons
jQuery serverCookieJar
jQuery autoSave
jQuery Puffer
jQuery iFrame Plugin
Cookie Plugin for jQuery
jQuery Spy - awesome plugin
Effect Delay Trick
jQuick - a quick tag creator for jQuery
Metaobjects

elementReady

原文地址: http://www.kollermedia.at/archive/2007/11/21/the-ultimate-jquery-plugin-list/



Eric.Zhou 2009-02-12 21:39 發(fā)表評論
]]>
Lightbox JS v2.0http://www.tkk7.com/rain1102/archive/2008/09/01/226177.htmlEric.ZhouEric.ZhouMon, 01 Sep 2008 12:17:00 GMThttp://www.tkk7.com/rain1102/archive/2008/09/01/226177.htmlhttp://www.tkk7.com/rain1102/comments/226177.htmlhttp://www.tkk7.com/rain1102/archive/2008/09/01/226177.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/226177.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/226177.html概要:

Lightbox JS 是一個簡單而又謙恭的用來把圖片覆蓋在當前頁面上的腳本. 它能被快速安裝并且運作于所有流行的瀏覽器.

最新更新 Version 2.0

  • 圖片集: 分組相關(guān)的圖片并且能輕松的導航它們
  • 視覺特效: 奇特的自適應調(diào)整
  • 向后兼容: yes!

點擊這里查看實例演示

如何使用:

步驟 1 - 安裝

1、Lightbox v2.0 使用 Prototype 框架和 Scriptaculous 效果庫. 你將需要外調(diào)這三個 Javascript 文件在你的 header. 
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

2、外調(diào) Lightbox CSS 文件 (或添加 Lightbox 樣式到你現(xiàn)行的樣式表中). 
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

3、檢查 CSS 并確定調(diào)用的 prev.gif 和 next.gif 文件在正確的位置. 同樣要確定調(diào)用的 loading.gif 和 close.gif 文件及 lightbox.js 文件在正確的位置.

步驟 2 - 激活

1、添加 rel="lightbox" 屬性到任何一個鏈接標簽去激活lightbox. 例如:
<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
可選擇項
: 使用 title 屬性加上說明.

2、如果你有一套你想分組的相關(guān)圖片, 接著上一部并且又在 rel 屬性中添加一個帶方括號的組名. 例如:
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>

3、沒有限定每個頁面的圖片組數(shù)量和每個圖片組圖片的數(shù)量. 瘋了!

下載: Lightbox v2.04



Eric.Zhou 2008-09-01 20:17 發(fā)表評論
]]>
為jmesa表格的date類型數(shù)據(jù)加filterhttp://www.tkk7.com/rain1102/archive/2008/06/20/209456.htmlEric.ZhouEric.ZhouFri, 20 Jun 2008 06:59:00 GMThttp://www.tkk7.com/rain1102/archive/2008/06/20/209456.htmlhttp://www.tkk7.com/rain1102/comments/209456.htmlhttp://www.tkk7.com/rain1102/archive/2008/06/20/209456.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/209456.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/209456.html<jmesa:htmlColumn
    property="born"
   pattern="MM/yyyy"
    cellEditor="org.jmesa.view.editor.DateCellEditor"/>

package com.founder.web.ext;

import Java.util.Date;
import Java.util.HashMap;
import Java.util.Map;

import org.jmesa.core.filter.DateFilterMatcher;
import org.jmesa.core.filter.FilterMatcher;
import org.jmesa.core.filter.FilterMatcherMap;
import org.jmesa.core.filter.MatcherKey;

public class DateFilterMatcherMap implements FilterMatcherMap {

 public Map<MatcherKey, FilterMatcher> getFilterMatchers() {
  Map<MatcherKey, FilterMatcher> filterMatcherMap = new HashMap<MatcherKey, FilterMatcher>();
  filterMatcherMap.put(new MatcherKey(Date.class, "born"), new DateFilterMatcher("MM/dd/yyyy"));
  return filterMatcherMap;
 }

}

現(xiàn)在需要修改tableFacade標簽為

<jmesa:tableFacade
    id
="tag"
    filterMatcherMap="com.founder.web.ext.DateFilterMatcherMap"


Eric.Zhou 2008-06-20 14:59 發(fā)表評論
]]>
JavaScript類庫 - Ricohttp://www.tkk7.com/rain1102/archive/2008/05/13/200217.htmlEric.ZhouEric.ZhouTue, 13 May 2008 07:28:00 GMThttp://www.tkk7.com/rain1102/archive/2008/05/13/200217.htmlhttp://www.tkk7.com/rain1102/comments/200217.htmlhttp://www.tkk7.com/rain1102/archive/2008/05/13/200217.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/200217.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/200217.htmlApache License的,一個免費使用的東東。
Rico (http://openrico.org/)是開源的JavaScript類庫,用來創(chuàng)建豐富的internet應用。
1、可以方便地制作很玄地圓角矩形。
2、可以設(shè)置TAB面板
3、支持DRAG&DROP
4、提供一個LiveGrid的數(shù)據(jù)表格,支持Title Sorting和Page splite
5、提供一個Ajax引擎。
6、提供一個色彩庫,默認一些色彩。
7、主頁是http://openrico.org/rico/home.page。 

因為Rico是建立在Prototype類庫之上的,所以你在使用Rico的時候必須對Prototype進行引用:
<script type="text/javascript"
 src="prototype.js">
</script>
<script type="text/javascript"
 src="rico.js">
</script>



Eric.Zhou 2008-05-13 15:28 發(fā)表評論
]]>
jMakihttp://www.tkk7.com/rain1102/archive/2008/04/08/191499.htmlEric.ZhouEric.ZhouTue, 08 Apr 2008 07:10:00 GMThttp://www.tkk7.com/rain1102/archive/2008/04/08/191499.htmlhttp://www.tkk7.com/rain1102/comments/191499.htmlhttp://www.tkk7.com/rain1102/archive/2008/04/08/191499.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/191499.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/191499.htmlDojo,Scriptaculus,Yahoo UI Widgets,Spry,DHTML Goodies,和Google等組件庫。jMaki提供為這些widget組件庫提供了一個公共接口以便讓你可以在同一頁面中一起使用這些組件庫。如果你有興趣利用jMaki項目來快速開發(fā)Web應用程序,可以使用NetBeans 5.5的jMaki插件。這個插件可以直接把jMaki組件拖放到JSP頁面中。如果不熟悉該插件可以通過其網(wǎng)站提供一段視頻來學習。

Eric.Zhou 2008-04-08 15:10 發(fā)表評論
]]>
ajax jsp 無刷新上傳文件http://www.tkk7.com/rain1102/archive/2008/03/19/187170.htmlEric.ZhouEric.ZhouWed, 19 Mar 2008 02:23:00 GMThttp://www.tkk7.com/rain1102/archive/2008/03/19/187170.htmlhttp://www.tkk7.com/rain1102/comments/187170.htmlhttp://www.tkk7.com/rain1102/archive/2008/03/19/187170.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/187170.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/187170.htmlajax 是無法實現(xiàn)上傳文件的,可以想一下ajax與后臺通信都是通過傳遞字符串,怎么能傳遞文件呢?其實出于安全考慮js是不能操作文件的,所以就不要再說用ajax來實現(xiàn)文件的上傳了,這是不可能的。
    而本文實現(xiàn)的文件上傳也是無頁面刷新的,可以說是一種"類似AJAX"方法。
    開始之前先說兩句無關(guān)的,其實在ajax出現(xiàn)之前,web應用也可以是無刷新的,那時大多通過IFrame來做到這一點。當然Ajax出現(xiàn)之后,人們一窩蜂地投奔Ajax 的陣營了,iFrame 就乏人問津了。但是用iFrame來實現(xiàn)無刷新上傳文件確實一個很好的選擇。ps:Ajax技術(shù)基本上可以說是由google公司帶起來的,但少Gmail中上傳文件用的還是 IFrame,所以說使用IFrame來上傳文件是最好的選擇。
    我在這里這里用的技術(shù)是jsp,其實asp,php等也是一樣可以這么實現(xiàn)的
    一共兩個文件就可實現(xiàn):index.html 和 upload.jsp
--index.html
  1. <html>   
  2. <body>   
  3.   
  4. <form action="upload.jsp" id="form1" name="form1" encType="multipart/form-data"  method="post" target="hidden_frame" >   
  5.     <input type="file" id="file" name="file" style="width:450">   
  6.     <INPUT type="submit" value="上傳文件"><span id="msg"></span>   
  7.     <br>   
  8.     <font color="red">支持JPG,JPEG,GIF,BMP,SWF,RMVB,RM,AVI文件的上傳</font>                 
  9.     <iframe name='hidden_frame' id="hidden_frame" style='display:none'></iframe>   
  10. </form>   
  11.   
  12. </body>   
  13. </html>   
  14.   
  15. <script type="text/javascript">   
  16. function callback(msg)   
  17. {   
  18.     document.getElementById("file").outerHTML = document.getElementById("file").outerHTML;   
  19.     document.getElementById("msg").innerHTML = "<font color=red>"+msg+"</font>";   
  20. }   
  21. </script>  


 index.html 中主要要做的就是寫一個 form 和 iframe ,并把 form 的 target 設(shè)為 iframe 的名字,注意要把 iframe 設(shè)為不可見,其他的都是正常的文件上傳的寫法,這樣刷新的頁面就是這個隱藏的 Iframe ,而在 index.html 中是不會有頁面刷新的,js的 callback 方法是回調(diào)方法。用于清空文件上傳框和顯示后臺信息,注意清空文件上傳框的方法,和普通方法有點不一樣。

--upload.jsp
  1. <%@ page language="Java" contentType="text/html; charset=gb2312" %>   
  2. <%@ page import="com.jspsmart.upload.SmartUpload"%>   
  3.   
  4. <%   
  5.     //新建一個SmartUpload對象   
  6.     SmartUpload su = new SmartUpload();   
  7.   
  8.     //上傳初始化   
  9.     su.initialize(pageContext);   
  10.   
  11.     // 設(shè)定上傳限制   
  12.     //1.限制每個上傳文件的最大長度。   
  13.     su.setMaxFileSize(10000000);   
  14.   
  15.     //2.限制總上傳數(shù)據(jù)的長度。   
  16.     su.setTotalMaxFileSize(20000000);   
  17.   
  18.     //3.設(shè)定允許上傳的文件(通過擴展名限制),僅允許doc,txt文件。   
  19.     su.setAllowedFilesList("doc,txt,jpg,rar,mid,waw,mp3,gif");   
  20.        
  21.     boolean sign = true;   
  22.        
  23.     //4.設(shè)定禁止上傳的文件(通過擴展名限制),禁止上傳帶有exe,bat,jsp,htm,html擴展名的文件和沒有擴展名的文件。   
  24.     try {   
  25.         su.setDeniedFilesList("exe,bat,jsp,htm,html");   
  26.   
  27.         //上傳文件   
  28.         su.upload();   
  29.         //將上傳文件保存到指定目錄   
  30.         su.save("c:\\");  
  31.  
  32.     } catch (Exception e) {  
  33.         e.printStackTrace();  
  34.         sign = false;  
  35.     }  
  36.     if(sign==true)  
  37.     {  
  38.         out.println("<script>parent.callback('upload file success')</script>");  
  39.     }else  
  40.     {  
  41.         out.println("<script>parent.callback('upload file error')</script>");   
  42.     }   
  43. %>   




upload.jsp 中只要注意最后輸出的格式就可以了。其實原理就是輸出一段js代碼到 iframe 中,然后在iframe中來控制它的父頁面。

    OK,至此一個無刷新的頁面上傳組件就做好了,
不要忘了在 WEB-INF/lib 下加上必須的 jspSmartUpload.jar 包
    需要說明的是使用Iframe來上傳,狀態(tài)欄還是會有刷新的,因為iframe 中的頁面刷新了嘛,但是外部頁面,就是你所看到的頁面是沒有刷新的,所以也可以說是類似Ajax上傳。


Eric.Zhou 2008-03-19 10:23 發(fā)表評論
]]>
Ajax.Updater http://www.tkk7.com/rain1102/archive/2008/03/18/187055.htmlEric.ZhouEric.ZhouTue, 18 Mar 2008 09:49:00 GMThttp://www.tkk7.com/rain1102/archive/2008/03/18/187055.htmlhttp://www.tkk7.com/rain1102/comments/187055.htmlhttp://www.tkk7.com/rain1102/archive/2008/03/18/187055.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/187055.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/187055.htmlSyntax
  new Ajax.Updater(container, url, options);
// make a HTTP request to the specified URL and update the 'container' element.

Note: to only update a div on success, you may optionally substitute a property list for a simply element id (ie {success:’div_name’} instead of ‘div_name’)

Options

Option Default value Description
asynchronous true Type of request
evalScripts false When set as “true”, scripts in requested url are evaluated
method ‘post’ Lets you decide whether to use Get or Post for the request to the server
contentType ‘application/x-www-form-urlencoded’ Allows you to set the content-type sent to the server
encoding ‘UTF-8’ Allows you to determine the encoding type information given to the server
parameters ’’ Allows you to attach parameters to your AJAX request. Most common: parameters:Form.serialize(this)
postBody ’’ Specify data to post. Something like: postBody:’thisvar=true&thatvar=Howdy’ How does this differ from parameters?
username ’’
password ’’
requestHeaders ’’ Allows you to override the headers, see the Prototype AJAX options for details
onComplete ’’ Function to call on completion of request
onSuccess ’’ Function to call on successful completion of request
onFailure ’’ Function to call on failed request
onException ’’ Function to call on failed request (e.g. attempted cross-site request)
on + Status Code ’’ on404 etc. raise an event when given status code is encountered.
insertion None Instead of inserting the response in the existing content (possibly overwriting it) you can pass a valid Insertion object, such as Insertion.Top, Insertion.Bottom, Insertion.Before or Insertion.After.

Hint: If you have set evalScripts:true the script you call (the url parameter) must return a header of ‘Content-Type: text/javascript’ else the browser will not execute it.



Eric.Zhou 2008-03-18 17:49 發(fā)表評論
]]>
在使用struts2的datetimepicker標簽時候遇到JS錯誤:dojo未定義錯誤http://www.tkk7.com/rain1102/archive/2008/02/25/181907.htmlEric.ZhouEric.ZhouMon, 25 Feb 2008 02:18:00 GMThttp://www.tkk7.com/rain1102/archive/2008/02/25/181907.htmlhttp://www.tkk7.com/rain1102/comments/181907.htmlhttp://www.tkk7.com/rain1102/archive/2008/02/25/181907.html#Feedback6http://www.tkk7.com/rain1102/comments/commentRss/181907.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/181907.html <%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../../commons/taglibs.jsp"%>
<s:datetimepicker label="releaseTime" name="releaseTime"/>

時間控件沒有顯示出來,而報JS錯誤:dojo未定義錯誤

解決辦法:
在頁面的<head>標簽中加入<s:head /> 就可以了
。。。
<head>
<title>Struts 2 Cool Tags - Others</title>
.....
<s:head /> 
</head>
。。。

Eric.Zhou 2008-02-25 10:18 發(fā)表評論
]]>
在Struts 2中使用JSON Ajax支持http://www.tkk7.com/rain1102/archive/2008/02/20/180907.htmlEric.ZhouEric.ZhouWed, 20 Feb 2008 09:02:00 GMThttp://www.tkk7.com/rain1102/archive/2008/02/20/180907.htmlhttp://www.tkk7.com/rain1102/comments/180907.htmlhttp://www.tkk7.com/rain1102/archive/2008/02/20/180907.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/180907.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/180907.html  簡單地說,JSON插件允許我們在JavaScript中異步調(diào)用Action,而且Action不再需要使用視圖資源來顯示該Action里的狀態(tài)信息,而是由JSON插件負責將Action里的狀態(tài)信息返回給調(diào)用頁面——通過這種方式,就可以完成Ajax交互。

  Struts2提供了一種可插拔方式來管理插件,安裝Struts2的JSON插件與安裝普通插件并沒有太大的區(qū)別,一樣只需要將Struts2插件的JAR文件復制到Web應用的WEB-INF/lib路徑下即可。

  安裝JSON插件按如下步驟進行:

  (1)登陸http://code.google.com/p/jsonplugin/downloads/list站點,下載Struts2的JSON插件的最新版本,當前最新版本是0.7,我們可以下載該版本的JSON插件。

  (2)將下載到的jsonplugin-0.7.jar文件復制到Web應用的WEB-INF路徑下,即可完成JSON插件的安裝。

  實現(xiàn)Actio邏輯

  假設(shè)wo,en輸入頁面中包含了三個表單域,這三個表單域?qū)τ谌齻€請求參數(shù),因此應該使用Action來封裝這三個請求參數(shù)。三個表單域的name分別為field1、field2和field3。

  處理該請求的Action類代碼如下:  
public class JSONExample
  {
  //封裝請求參數(shù)的三個屬性
  private String field1;
  private transient String field2;
  private String field3;
  //封裝處理結(jié)果的屬性
  private int[] ints = {10, 20};
  private Map map = new HashMap();
  private String customName = "custom";
  //三個請求參數(shù)對應的setter和getter方法
  public String getField1()
  {
  return field1;
  }
  public void setField1(String field1)
  {
  this.field1 = field1;
  }
  //此處省略了field1和field2兩個字段的setter和getter方法
  ...
  //封裝處理結(jié)果的屬性的setter和getter方法
  public int[] getInts()
  {
  return ints;
  }
  public void setInts(int[] ints)
  {
  this.ints = ints;
  }
  public Map getMap()
  {
  return map;
  }
  public void setMap(Map map)
  {
  this.map = map;
  }
  //使用注釋語法來改變該屬性序列化后的屬性名
  @JSON(name="newName")
  public String getCustomName()
  {
  return this.customName;
  }
  public String execute()
  {
  map.put("name", "yeeku");
  return Action.SUCCESS;
  }
  }
  在上面代碼中,使用了JSON注釋,注釋時指定了name域,name域指定Action屬性被序列化成JSON對象的屬性名。除此之外,JSON注釋還支持如下幾個域:

      serialize:設(shè)置是否序列化該屬性

  deserialize:設(shè)置是否反序列化該屬性。

  format:設(shè)置用于格式化輸出、解析日期表單域的格式。例如"yyyy-MM-dd'T'HH:mm:ss"。

  配置該Action與配置普通Action存在小小的區(qū)別,應該為該Action配置類型為json的Result。而這個Result無需配置任何視圖資源。

  配置該Action的struts.xml文件代碼如下: 
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<package name="example" extends="json-default">
<action name="JSONExample" class="lee.JSONExample">
<result type="json"/>
</action>
</package>
</struts>  
  在上面配置文件中有兩個值得注意的地方:

  第一個地方是配置struts.i18n.encoding常量時,不再是使用GBK編碼,而是UTF-8編碼,這是因為Ajax的POST請求都是以UTF-8的方式進行編碼的。

  第二個地方是配置包時,自己的包繼承了json-default包,而不再繼承默認的default包,這是因為只有在該包下才有json類型的Result。



Eric.Zhou 2008-02-20 17:02 發(fā)表評論
]]>
Adobe AIR正式版三月推出 要做RIA技術(shù)領(lǐng)導者http://www.tkk7.com/rain1102/archive/2008/02/20/180894.htmlEric.ZhouEric.ZhouWed, 20 Feb 2008 08:29:00 GMThttp://www.tkk7.com/rain1102/archive/2008/02/20/180894.htmlhttp://www.tkk7.com/rain1102/comments/180894.htmlhttp://www.tkk7.com/rain1102/archive/2008/02/20/180894.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/180894.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/180894.htmlAdobe 218日表示,將在三月發(fā)布Adobe AIRAdobe Integrated Runtime)正式版,要和微軟的Silverlight競逐豐富網(wǎng)絡(luò)應用程序RIARich Internet Application)市場。

所謂RIA就是以動畫、影音等多樣性打造網(wǎng)站的技術(shù),而其底層除了微軟已在去年推出的Silverlight之外,就屬Adobe開發(fā)代號為ApolloAIR,目前仍在Beta版。不過Adobe香港暨臺灣區(qū)總經(jīng)理黃耀輝今天表示,AIR正式版將在三月推出,希望在RIA技術(shù)中取得市場領(lǐng)導地位。

RIA
可以在網(wǎng)站中做出交互式的應用程序,也可以說是實現(xiàn)Web 2.0概念的工具。例如可以做到交互式的電子下單系統(tǒng)、航空公司訂票系統(tǒng)等等。微軟在去年發(fā)表Silverlight時就展示出寶來證券、中華航空等企業(yè)應用。而Adobe希望利用AIR做為開發(fā)平臺,再加上FlexFlash兩種工具,做到RIA的應用程序。

除了Adobe要以AIR做為RIA技術(shù)領(lǐng)導者外,微軟也積極耕耘這塊市場,去年才首度正式發(fā)表名為「銀光」的Silverlight 1.0,要搶攻Adobe耕耘已久的網(wǎng)站開發(fā)、設(shè)計市場。隨著Adobe即將推出AIR正式版,兩家廠商將展開正面對決。

對此微軟則是自信滿滿。臺灣微軟開發(fā)工具暨平臺推廣處產(chǎn)品營銷經(jīng)理胡德民表示,微軟三月時會在美國的Mix 08大會上發(fā)表Silverlight 2.0的產(chǎn)品藍圖,預計在今年就會正式發(fā)表。微軟原本只將更新版本命名為Silverlight 1.1,不過由于功能比前一版改進太多,因此在去年12宣布直接發(fā)表Silverlight 2.0

而去年9月首次發(fā)表的Silverlight 1.0版本,目前微軟尚不愿透露在臺灣地區(qū)的使用狀況,表示要晚一點才會公布。胡德民認為,RIA技術(shù)的成功必須視企業(yè)進入這項技術(shù)的狀況而定,微軟今年七、八月份將在臺灣舉行的Mix大會,會展示更多利用Silverlight打造的成功案例。另外胡德民也表示,AIR的目標群眾在于開發(fā)者(developer),而微軟則是希望開發(fā)者和設(shè)計者(designer)都能使用微軟技術(shù)。

微軟自去年開始積極搶攻原是Adobe天下的開發(fā)市場,推出網(wǎng)頁設(shè)計工具平臺Expression Studio,其中有網(wǎng)頁建置工具、互動設(shè)計工具等等,都被視為和AdobeFlash打?qū)ε_。不過Adobe今天公布2007年的臺灣區(qū)營業(yè)成長為30%,黃耀輝說,仍持續(xù)穩(wěn)定成長,并沒有受到微軟加入開發(fā)市場的影響。

另外,Adobe今年在臺灣除了深耕RIA技術(shù)外,仍持續(xù)發(fā)展AcrobatCreative Suite 3等產(chǎn)品,并在政府、金融、制造業(yè)間深耕Acrobat。手機端的應用也會有新的進展,和中華電信在手機上的Flash Cast服務(wù)今年就會推出



Eric.Zhou 2008-02-20 16:29 發(fā)表評論
]]>
Jmesahttp://www.tkk7.com/rain1102/archive/2008/01/17/175829.htmlEric.ZhouEric.ZhouThu, 17 Jan 2008 01:24:00 GMThttp://www.tkk7.com/rain1102/archive/2008/01/17/175829.htmlhttp://www.tkk7.com/rain1102/comments/175829.htmlhttp://www.tkk7.com/rain1102/archive/2008/01/17/175829.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/175829.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/175829.htmlJmesa是ExtremeTable項目重新開發(fā)一個的Html表格組件,提供過濾、排序、分頁、數(shù)據(jù)導出等功能。Jmesa非常易于使用,可按自己的需求進行擴展。JMesa需要JDK1.5以上的環(huán)境。
該項目主頁:http://code.google.com/p/jmesa/

Eric.Zhou 2008-01-17 09:24 發(fā)表評論
]]>
如何在dwr的回調(diào)函數(shù)中傳遞多個參數(shù)http://www.tkk7.com/rain1102/archive/2007/12/28/171357.htmlEric.ZhouEric.ZhouFri, 28 Dec 2007 15:42:00 GMThttp://www.tkk7.com/rain1102/archive/2007/12/28/171357.htmlhttp://www.tkk7.com/rain1102/comments/171357.htmlhttp://www.tkk7.com/rain1102/archive/2007/12/28/171357.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/171357.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/171357.html       var num = countryId.indexOf("Country");
      var prefix = countryId.substr(0,num);
      var countryId = document.getElementById(countryId).value;
 
      loveService.getProvincesByCountry(countryId, function(data){
      callBackProvices(data,prefix);
   });
   resetProvince(prefix+"Province");
   resetCity(prefix+"City");
  }
 
  function callBackProvices(data, prefix) {
      var provinceId = prefix+'Province';
   DWRUtil.removeAllOptions(provinceId);
   DWRUtil.addOptions(provinceId, arrayObject, 'value', 'name');
   DWRUtil.addOptions(provinceId, data);
  }

 



Eric.Zhou 2007-12-28 23:42 發(fā)表評論
]]>
模塊介紹:jRatinghttp://www.tkk7.com/rain1102/archive/2007/11/29/163956.htmlEric.ZhouEric.ZhouThu, 29 Nov 2007 03:49:00 GMThttp://www.tkk7.com/rain1102/archive/2007/11/29/163956.htmlhttp://www.tkk7.com/rain1102/comments/163956.htmlhttp://www.tkk7.com/rain1102/archive/2007/11/29/163956.html#Feedback0http://www.tkk7.com/rain1102/comments/commentRss/163956.htmlhttp://www.tkk7.com/rain1102/services/trackbacks/163956.html簡介:
這個模塊使用 jQuery 技術(shù)為節(jié)點提供評分功能,當 javascript 被禁止時,使用標準形式,如果啟用 javascript 就可以通過圖片 (如五星) 動態(tài)進行評分。

 

這個模塊能夠與 views 模塊協(xié)作,它提供一個 views 字段,讓評分結(jié)果可以通過 views 顯示。

 

鏈接:

 

http://drupal.org/project/jrating


Eric.Zhou 2007-11-29 11:49 發(fā)表評論
]]>
主站蜘蛛池模板: 亚洲av无码专区在线电影| 亚洲国产av一区二区三区| 午夜无码A级毛片免费视频| 国产av无码专区亚洲av毛片搜 | 亚洲第一成年人网站| 亚洲精品成人a在线观看| 在线免费观看一区二区三区| 在线观看免费中文视频| 中文字幕乱码免费看电影| 免费播放国产性色生活片| 亚洲国产精品自在自线观看| 亚洲日产2021三区| 亚洲伊人久久大香线蕉苏妲己| 亚洲日韩av无码| 亚洲人AV永久一区二区三区久久| 日韩a在线观看免费观看| 毛片免费观看网站| 久久WWW色情成人免费观看| 又粗又大又黑又长的免费视频 | 亚洲人成依人成综合网| 亚洲人成色777777在线观看| 亚洲人成人网站在线观看| 伊人久久亚洲综合影院| 国产成人aaa在线视频免费观看 | 亚洲国产精品自在线一区二区| 亚洲日韩中文无码久久| 亚洲精品中文字幕无码蜜桃| 狠狠亚洲狠狠欧洲2019| 伊人久久综在合线亚洲91| 亚洲永久精品ww47| 亚洲美女又黄又爽在线观看| 亚洲人成人一区二区三区| 亚洲国产精品无码成人片久久 | 在线观看免费黄网站| 国产成人无码区免费内射一片色欲 | 亚洲av综合av一区二区三区 | 天天摸天天操免费播放小视频| 性xxxx视频播放免费| 在线观看免费大黄网站| 国产又大又黑又粗免费视频| 亚洲成a人片在线观看久|