??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品一区二区三区四区高清,精品资源在线看,日本一区二区免费在线http://www.aygfsteel.com/sealyu/category/42744.html--- The devil's in the Detailszh-cnWed, 09 Dec 2009 01:27:11 GMTWed, 09 Dec 2009 01:27:11 GMT60 Ext FormPanel submit 提交与Ext.Ajax.request提交的区别(转)http://www.aygfsteel.com/sealyu/archive/2009/12/06/304934.htmlsealsealSun, 06 Dec 2009 12:17:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/12/06/304934.htmlhttp://www.aygfsteel.com/sealyu/comments/304934.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/12/06/304934.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/304934.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/304934.html
前置Q?/div>
后台成功q回字符Ԍ{success:true,msg:'操作成功Q?}
后台p|q回字符Ԍ{success:false,errors:'操作p|Q?}
当submi提交Ӟaction不存在后台返回下囑֭W串Q?/div>
 
下面所有的action不存在,是指url路径不存?/div>
 
FormPanel 提交代码如下Q?/div>
var G = new Ext.form.FormPanel({})
 
G.getForm().submit({//客户端的数据提交l服务器
                    url:wayfoon.MMS.DataPage +'/ext2Upload.action',   
                    //waitMsg:"正在提交表单数据Q请E候。。。。。?,    
                    failure:function(form, action){
                        Ext.MessageBox.alert('警告', action.result.errors);       
                    },     
                    success: function(form, action){
                        Ext.MessageBox.alert('信息', action.result.msg);
                     }    
                });
Ҏ后台json 字符?success的|ture/falseQ自动选择failure或者successQ也可以捕捉前台错误Q走failure程Q,比如数据非法而被强制提交Ӟ
后台字符串需要通过action.result 转成json 字符Ԍ供我们按习惯的方法用,
 
对于后台异常处理Q比?action不存在,则无能ؓ力,会出JavaScript错误Q?/div>
错误处,ext-all.js的代?/div>
this.decode = function(json) {
        //alert(json);
  return eval("(" + json + ")")
 }
原因是无法将上图Q如图)的字W串转成json字符ԌD无法判断走哪个流E,而正常情况下Q返回的?{success:true,msg:'操作成功Q?}或其他?/div>
试了上面代码用try{}catch (){} q是不能解决JavaScript错误Q我们一般可以避免这U后台错误,如果非得解决的话Q不知道有没有好的解x法?/div>
 
 
Ext.Ajax.request提交代码如下Q?/div>
Ext.Ajax.request({
    url:wayfoon.MMS.DataPage+'/cpSMS.action?action=submitSMS',
    method:'POST',
    params:'id='+id,
    success:function(form,action){
        var obj = Ext.util.JSON.decode(form.responseText);
        if(obj.success==true)
        {
            Ext.Msg.alert('提示',obj.msg);
            ds.reload();
        }
        else
        {
            //Ext.Msg.alert('提示',obj.errors);
            Ext.Msg.alert('提示',obj.msg);
        } 
    },
    failure:function(form,action){
        Ext.Msg.alert('警告','pȝ错误');
    }
});
后台字符串通过Ext.util.JSON.decode 转成json字符?/div>
不能自动Ҏjson字符串success的值来选择程 Q需要根据obj.success的值来判断走哪个流E?/div>
 
该failure:可以捕捉pȝ异常Q比如,数据未曾提交到后台或action 不存在,此时走failure 程



seal 2009-12-06 20:17 发表评论
]]>Ext.MessageBox(?http://www.aygfsteel.com/sealyu/archive/2009/12/04/304821.htmlsealsealFri, 04 Dec 2009 12:26:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/12/04/304821.htmlhttp://www.aygfsteel.com/sealyu/comments/304821.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/12/04/304821.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/304821.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/304821.html

一、提C框(Ext.MessageBox.alert  ?nbsp; Ext.Msg.alert)

alertString title, String msg, [Function fn], [Object scope] ) :

title:标题

msg:昄内容

fn:回调函数

scope:作用?/p>

Js代码 复制代码
  1. <script type="text/javascript">   
  2.         Ext.onReady( function(){   
  3.                         Ext.MessageBox.alert('Alert','弹出H口Alert',function(){alert('abc')});                  
  4.                }   
  5.        );   
  6. </script>  
Js代码
  1. <script type="text/javascript">  
  2.         Ext.onReady( function(){  
  3.                         Ext.MessageBox.alert('Alert','弹出H口Alert',function(){alert('abc')});                 
  4.                }  
  5.        );  
  6. </script>  

二、对话框(Ext.MessageBox.confirm  ?nbsp; Ext.Msg.confirm)

confirmString title, String msg, [Function fn], [Object scope] )

title:标题

msg:昄内容

fn:回调函数

Js代码 复制代码
  1. <script type="text/javascript">   
  2.     Ext.onReady( function(){   
  3.             Ext.MessageBox.confirm( "L?"是否要删除指定内?function(button,text){   
  4.                 alert(button);   
  5.             } );   
  6.         }   
  7.     );   
  8. </script>  
Js代码
  1. <script type="text/javascript">  
  2.     Ext.onReady( function(){  
  3.             Ext.MessageBox.confirm( "L?, "是否要删除指定内?, function(button,text){  
  4.                 alert(button);  
  5.             } );  
  6.         }  
  7.     );  
  8. </script>  

三、对话框(Ext.MessageBox.prompt ?Ext.Msg.prompt )

promptString title, String msg, [Function fn], [Object scope] )

title:标题

msg:昄内容

fn:回调函数

Js代码 复制代码
  1. <script type="text/javascript">   
  2.     Ext.onReady( function(){   
  3.             Ext.MessageBox.prompt( "输入提示?"误入您的年?function(button,text){   
  4.                 alert(button);   
  5.                 alert(text);   
  6.             } );   
  7.         }   
  8.     );   
  9. </script>  
Js代码
  1. <script type="text/javascript">  
  2.     Ext.onReady( function(){  
  3.             Ext.MessageBox.prompt( "输入提示?, "误入您的年?, function(button,text){  
  4.                 alert(button);  
  5.                 alert(text);  
  6.             } );  
  7.         }  
  8.     );  
  9. </script>  

四、对话框(Ext.MessageBox.show ?Ext.MsgBox.show)

Js代码 复制代码
  1. Ext.onReady( function(){   
  2.     Ext.MessageBox.show( {   
  3.         title:"保存数据",   
  4.         msg:"你已l作了一些数据修改,是否要保存当前内容的修改Q?,   
  5.         buttons:Ext.Msg.YESNOCANCEL,   
  6.         fn:save,   
  7.         icon:Ext.MessageBox.QUESTION});   
  8.     }   
  9. );  
Js代码
  1. Ext.onReady( function(){  
  2.     Ext.MessageBox.show( {  
  3.         title:"保存数据",  
  4.         msg:"你已l作了一些数据修改,是否要保存当前内容的修改Q?,  
  5.         buttons:Ext.Msg.YESNOCANCEL,  
  6.         fn:save,  
  7.         icon:Ext.MessageBox.QUESTION});  
  8.     }  
  9. ); 
a

1.Ext.MessageBox.alert()Ҏ
有四个参敎ͼalert( title , msg , function(){} Qthis)
其中titleQmsg为必选参敎ͼfunction为可选参敎ͼ在关闭弹出窗口后触发,可以传入点击的按钮的idQ第四个参数
scope:指回调函C用域?/p>

Ext.Msg.alert(”Notice”,”hello world!”);  //alert会阻塞程序的执行Q而Ext版的alert是异步执?/span>
Ext.Msg.alert(”Notice”,”<font color=red>hello world!</font>”); //支持html格式
Ext.Msg.alert(”Notice”,”<font color=red>hello world!</font>”,function callback(id){alert(’您点的是’+id);});

2.Ext.MessageBox.confirm()Ҏ

基本上同alert()Ҏ一模一栗?注意q点Q?/p>

Ext.MessageBox.confirm(title,msg,function(e){alert(e);});

q个参数e是什么?它是你点ȝ弹出框的按钮的|三种|yes,no,cancel. Alert()Ҏ也是如此Q不q只有两U|okQcancel.

回调函数可以传入一唯一参数Q单L钮的idQ点击退出按钮也会触发此事g

3.Ext.MessageBox.prompt()Ҏ
有五个参敎ͼ比前面alertҎ多一个是否多行?/p>

Ext.MessageBox.prompt(title,msg);
Ext.Msg.prompt(’Notice’,'误入你的姓名:’,function callback(id,msg){alert(’单击的按钮IDQ?#8217;+id+’"n您输入的姓名是:’+msg);},this,false);
//输入”javachen”,点击ok按钮Q弹?/span>单击的按钮IDQ?span style="color: #008000;">OK 您输入的姓名是:javachen
Ext.MessageBox.prompt(title,msg,function(e,text){alert(e+-+text);},this,true);//true为多行,this表示作用?/span>
4.Ext.MessageBox.show()Ҏ
功能很强大,采用config配置形式Q比前面的方法用更方便?参数很多Q在此列举最常用的配|参敎ͼ
1.animEl:对话框弹出和关闭时的动画效果Q比如设|ؓ“id1”Q则从id1处弹出ƈ产生动画Q收~则相反
2.buttons:弹出框按钮的讄Q主要有以下几种QExt.Msg.OK,
Ext.Msg.OKCANCEL,
Ext.Msg.CANCEL,
Ext.Msg.YESNO,
Ext.Msg.YESNOCANCEL
你也可以自定义按钮上面的字:{
ok,我本来是ok?/span>}?若设为falseQ则不显CZQ何按?
3.closable:如果为falseQ则不显C右上角的小叉叉Q默认ؓtrue?br /> 4.msg:消息的内?/span>
5.title:标题
6.fn:关闭弹出框后执行的函?br /> 7.iconQ弹出框内容前面的图标,取gؓExt.MessageBox.INFOQ?br /> Ext.MessageBox.ERROR,
Ext.MessageBox.WARNING,
Ext.MessageBox.QUESTION
8.width:弹出框的宽度Q不带单?br /> 9.promptQ设为trueQ则弹出框带有输入框
10.multilineQ设为trueQ则弹出框带有多行输入框
11.progress:设ؓtrueQ显C度条Q(但是是死的)
12.progressText:昄在进度条上的?br /> 13.waitQ设为trueQ动态显Cprogress
14.waitConfig:配置参数Q以控制昄progress
例子Q?/span>
Ext.Msg.show({
title:’Notice’,
msg:’误入您的姓名!’,
width:300,
prompt:true,
//multiline:true,
//wait:true,
//progress:true,
//progressText:’progressing’,
closable:true,
modal:true,

buttons:Ext.Msg.OKCANCEL,
icon:Ext.Msg.INFO
});


5.Ext.MessageBox.wait()
参数 msgQ显CZ?nbsp; titleQ标?     configQ配|信?/div>
例子Q?/div>
Ext.Msg.wait(’L待,操作正在q行?#8217;,'Notice’);
Ext.Msg.wait(’L待,操作正在q行中!’,'Notice’,
{
text:’processing’,
duration:2700,   //q度条在被重|前q行的时?/span>
interval:300,        //q度条的旉间隔
increment:10,      //q度条的分段数量
fn:function callback(){
alert(”complete”);
}
});
6.Ext.MessageBox.hide()
把显C着的当前message box隐藏h?br /> 参数: ?       Returns:   Ext.MessageBox
7.Ext.MessageBox.updateProgressQ)
Ext.MessageBox.updateProgress(value,”ProgressText”,”msg”)  //(三个参数Q看名字q道意?Q?/span> 注意value?-1之间的数Q表C度条的进?

8.修改默认的按钮文?/span>
Ext.Msg.buttonText={
yes:’ yes’,
no:’no’,
ok:’ok’,
cancel:’cancel’
};
Ext.Msg.buttonText.yes=’Yes’;
9.动态跟新提C框
1)跟新提示文字
var msgBox = Ext.MessageBox.show({
title:’提示’,
msg:’动态跟新的信息文字’,
modal:true,
buttons:Ext.Msg.OK
})
//Ext.TaskMgr是一个功能类Q用来定时执行程序,
//在这里我们用它来定时触发提CZ息的更新?/span>
Ext.TaskMgr.start({
run:function(){
msgBox.updateText(’会动的时_’+new Date().format(’Y-m-d g:i:s A’));
},
interval:1000
});
2).跟新q度条及提示信息
var msgBox = Ext.MessageBox.show({
title:’提示’,
msg:’动态跟新的q度条和信息文字’,
modal:true,
width:300,
progress:true
})

var count = 0;//滚动条被h的次?/span>
var percentage = 0;//q度癑ֈ?/span>
var progressText = ”;//q度条信?/span>

Ext.TaskMgr.start({
run:function(){
count++;   //h10ơ后关闭信息提示对话?/span>
if(count > 10){
msgBox.hide();
}
//计算q度
percentage = count/10;
//生成q度条文?/span>
progressText = ‘当前完成度:’+percentage*100 + “%”;
//更新信息提示对话?/span>
msgBox.updateProgress(percentage,progressText,
‘当前旉Q?#8217;+new Date().format(’Y-m-d g:i:s A’));

},
interval:1000
});



seal 2009-12-04 20:26 发表评论
]]>Extjs 如何动态添加window的items(转)http://www.aygfsteel.com/sealyu/archive/2009/12/01/304384.htmlsealsealTue, 01 Dec 2009 07:50:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/12/01/304384.htmlhttp://www.aygfsteel.com/sealyu/comments/304384.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/12/01/304384.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/304384.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/304384.html <script type="text/javascript"> 

var user1 = new Ext.form.TextField({ })

var user2= new Ext.form.TextField({ })

var c_window = new Ext.Window({
       title: 'title',
        width: 950,
        height: 530,
        plain: true,
        closeAction: 'hide',
        defaults: { anchor: '95%' },
        items:[user1],
        modal: true,
        buttons: [{ text: '关闭', handler: function(){ c_window.hide(); } },
        { text: 'd',
        handler: function(){
        c_window.add(user2); // d新组?
        c_window.render(); // d后需要重新渲染一遍?} }] });

c_window.show();
</script>

seal 2009-12-01 15:50 发表评论
]]>
How to add a column with tools for each record?http://www.aygfsteel.com/sealyu/archive/2009/11/30/304257.htmlsealsealMon, 30 Nov 2009 06:57:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/11/30/304257.htmlhttp://www.aygfsteel.com/sealyu/comments/304257.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/11/30/304257.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/304257.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/304257.html
  • Approach 1
    • Use the array grid example in your packaged download array-grid.js
    • Add an extra column to the column model definition and a custom renderer.
  • {header: "Controls", 

    width: 60,

    sortable: false,

    renderer: function() {

    return '<div class="controlBtn">

    <img src="../shared/icons/fam/cog_edit.png"

    width="16" height="16"

    class="control_edit">

    <img src="../shared/icons/fam/folder_go.png"

    width="16" height="16"

    class="control_go"></div>';

    },

    dataIndex: 'company'}
      • Then you would setup an event handler on the click event.
    grid.on('click', function(e) {

    var btn = e.getTarget('.controlBtn');

    if (btn) {

    var t = e.getTarget();

    var v = this.getView();

    var rowIdx = v.findRowIndex(t);

    var record = this.getStore().getAt(rowIdx);

    var control = t.className.split('_')[1];

    switch (control) {

    case 'edit':

    console.log('edit this record - ' + record.id);

    break;

    case 'go':

    console.log('go to this record - ' + record.id);

    break;

    }

    }

    }, grid);
      • Add the following CSS rule in array-grid.html to give some padding and change the cursor.
    <style>

    .controlBtn img {

    padding-left: 4px;

    cursor: pointer;

    }

    </style>
      • Using this same method you could add as many tools as you would like in the controls section and always give them the css class "controls_{toolname}". Ideally you would break this out into an XTemplate so that you could simply pass in whatever tools you would like to use and output them on the grid as well.

    • Approach 2 utilizes a plugin as discussed here  :
    http://rowactions.extjs.eu/


    seal 2009-11-30 14:57 发表评论
    ]]>
    ExtJs----布局(?http://www.aygfsteel.com/sealyu/archive/2009/11/19/302952.htmlsealsealThu, 19 Nov 2009 09:00:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/11/19/302952.htmlhttp://www.aygfsteel.com/sealyu/comments/302952.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/11/19/302952.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/302952.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/302952.html阅读全文

    seal 2009-11-19 17:00 发表评论
    ]]>
    Springing Around with ExtJShttp://www.aygfsteel.com/sealyu/archive/2009/11/19/302934.htmlsealsealThu, 19 Nov 2009 07:21:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/11/19/302934.htmlhttp://www.aygfsteel.com/sealyu/comments/302934.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/11/19/302934.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/302934.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/302934.htmlWhile playing around more with ExtJS and Spring, I ran in to one of my favorite annoyances ?setting up a new project. I can create a new webapp in IDEA (or Eclipse) and add some dependencies, but it is still pretty empty. Maven can go a bit farther, but I don’t like how it handles transitive dependencies. None of these will really give me a good starting point out of the box without either copying a bunch of stuff over from other projects or writing a lot from scratch.

    To finally scratch that itch, and move further along the Spring & ExtJS path, I turned my demo project into a basic template. The zip archive that you can grab at the bottom is a fully-configured Spring web application, including Tiles, Spring Security, Spring MVC, custom JSON view, Transactions and a Datasource.

    To get started, grab the file, extract it to some directory. Open a shell, navigate to the Template directory and run the ant command ant dist. This will compile the whole project and create a Template.war file in the dist directory. Note, I use Java 6 for all development, so if you’re not at least at Java 5, you won’t be able to use this.

    Before you drop the war file into Tomcat’s webapp directory, you’ll need to setup the database. First, copy the jar files in lib/tomcat into Tomcat’s lib directory. This is the MySQL JDBC driver and the JTA files for transactions. You’ll then need to create a new database on your local MySQL instance called tomcat. For simplicity in development, create a user with all rights to the tomcat database. Here’s the code to run from a MySQL shell:

    create database tomcat;
    use tomcat;
    grant all on tomcat.* to tomcat@localhost identified by 'apache';

    Your other option is to just put in your MySQL root username and password. To do that, or change the connection string completely, edit context.xml under web/META-INF. If you don’t use MySQL, you will have to edit this file and also put the correct driver in Tomcat’s lib directory.

    Once you have the database setup, drop the Template.war file into your Tomcat webapps directory and startup Tomcat. Assuming Tomcat is configured to listen on port 8080, you can open the sample by browsing to http://localhost:8080/Template

    The application only has a couple pages. First, the login page:

    Login Page

    Spring Security is configured to route unauthenticated requests through this page for login. You can take a look at the applicationContext-security.xml file in WEB-INF to see how this was done. There are two users configured for now. User scott with a password of tiger and user bob with a password of password. Yes, not very clever, but it works. Scott is in both the ROLE_ADMIN and ROLE_USER roles, while Bob is only in ROLE_USER.

    If you login with scott, you’ll be taken to the index page, which looks like this:

    Home Page

    The index page simply contains a text box with a button. Entering a message and pressing the button results in an Ajax call to the server which echos the message back to the page. An HTML element in the middle of the page is updated with the result via JavaScript.

    You’ll notice in the footer of the page you can see the currently logged in user on the left, and a link to log out on the right. Clicking the log out link takes you to the logout page, which looks like this:

    Logout Page

    Again, nothing fancy. Just a message saying you have logged out and a link to login again. Use the login link to login as bob and try the echo functionality again. This time you get a different result:

    Not an Admin

    This demonstrates what happens with Spring Security via annotations. Here’s the echo method in the service layer:

    As you can see, the method is secured with an annotation indicating the user must be in the ROLE_ADMIN role to use the method. Bob is only in the ROLE_USER role, so the call to this service fails.

    The application makes use of a ResourceBundleMessageSource for the pages mapped through the htmlDispatch servlet. The login.jsp and logout.jsp don’t go through the dispatch servlet, so they can’t use the message bundle for the window and page title.

    There is way too much to this simple application to cover completely now, but I’ll give the highlights of what to go look at in the major configuration files. Paths are relative to the project root:

    1. web/WEB-INF/web.xml - notice that I configure two dispatch servlets. One catching *.htm and one *.json. This sets things up to treat Ajax requests differently. Spring Security is also configured here.
    2. web/WEB-INF/applicationContext.xml – typical application context for a Spring application. I turn on annotation handling with package scanning under the sample.core package. Apache Tiles is configured in this file, and I have also configured a Transaction Manager around the JDBC DataSource. You should tweak this based on your underlying persistence preferences. I’m a RowMapper fan, but you can plug in Hibernate or JPA.
    3. web/WEB-INF/htmlDispatch-servlet.xml - the context for web (*.htm) requests. This sets up the ResourceBundle for messages and a typical ViewResolver mapping the *.htm requests to jsp files under web/WEB-INF/jsp. Also configures component scanning for the sample.web package.
    4. web/WEB-INF/jsonDispatch-servlet.xml – the context for Ajax (*.json) requests. Configures component scanning for the sample.json package and specifies a custom Ajax ViewResolver. This will automagically serialize all ModelMaps returned out of the Controller responded to *.json requests to JSON.
    5. web/WEB-INF/applicationContext-security.xml – so simple to look at, yet so painful to figure out. This is the Spring Security configuration file. Although it looks deceptively simple, it was a beating to figure it all out. It enables annotation-driven security, which you saw on the EchoService above. It also sets up the form login and locks down all the pages. Note I leave the /resource directory open. This is where I put all my javascript, stylesheets and images. If you want to secure those resources, you’ll need to get more specific on the intercept-urls.
      Users are declared at the bottom. Passwords are clear text, which is fine for a trivial demo, but you would want to replace this with something more industrial-strength in a real application.
    6. web/WEB-INF/tiles-config.xml – the Apache Tiles configuration. I only setup one definition here to keep it simple.
    7. web/WEB-INF/jsp/layouts/baseLayout.jsp – the base layout used for tiles. I’m only inserting content at two locations in the template. In the HTML head section, I allow for an optional insert of headerContent. I use this to include JavaScripts specific to a page. The other content is within the center div called mainContent.
      Note that the body is pretty empty and that the divs all have the x-hidden class. This means they are not normally visible. I use an ExtJS Viewport for layout, which uses the contents of these divs.
    8. web/resources/javascripts/layout.js – this JavaScript file was included in the baseLayout.jsp above. It creates the Viewport using a border layout.
    9. web/resources/javascripts/index.js – the JavaScript file included for the index.jsp page. It decorates the plain HTML inputs on the page to do the cool Ajax stuff. Note towards the bottom how I use ExtJS to set focus on a form field and to bind the ENTER key to the submit button.
    10. web/resources/javascripts/login.js – the JavaScript file use for the login.jsp page. If you look at login.jsp, you’ll notice there is no form. Everything is created by ExtJS from the login.js file, including the cool box effect. One trick is that Spring Security wants a normal form POST for the login form. I override the form to do a standard submit instead of an Ajax submit and set the form action explicitly.

    This covers the major features. I’ll be using this as a base for other projects and will be expanding out my ExtJS demo. Since there are pretty much zero examples out there of tying together this stack, I hope this can be of use to some folks.

    Project Template

    • 2/28/2009 – upgrade to ExtJS 2.2.1, fixed compile issue on Linux, added in iBatis for ORM
    • 3/26/2009 – I’ve setup a dev server with the latest version of the template at CodeZombie.com so you can check it out without having to install. User scott/tiger for credentials. I’ll be updating this install with a more feature-rich demo application shortly
    • 3/28/2009 – changed around the project structure and build.xml to use Ivy for dependency management. Check the README.txt file in the root directory for the details.
    • 4/28/2009 – updated the included JSON encoder to be able to return JSON arrays by using the key _root in the model map. If this key is found, its content will be used as the root element of the return JSON instead of encoding the whole map. Also removed the unicode characters from StringScrubber to make the compiler on Linux happy.

    p.s. this pulls together a lot of jars and pieces from different folks to build the demo. If you use this for more than playing around, you need to make sure you respect whatever licenses the authors have in place.



    seal 2009-11-19 15:21 发表评论
    ]]>
    ExtJS中get、getDom、getCmp、getBody、getDoc的用(转)http://www.aygfsteel.com/sealyu/archive/2009/11/18/302854.htmlsealsealWed, 18 Nov 2009 14:13:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/11/18/302854.htmlhttp://www.aygfsteel.com/sealyu/comments/302854.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/11/18/302854.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/302854.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/302854.html
    1、getҎ
    getҎ用来得到一个Ext元素Q也是cd为Ext.Element的对象, Ext.ElementcLExt对DOM的封装,代表DOM的元素,可以为每一个DOM创徏一个对应的Element对象Q可以通过Element对象 上的Ҏ来实现对DOM指定的操作,比如用hideҎ可以隐藏元素、initDDҎ可以让指定的DOMh拖放Ҏ等。getҎ其实? Ext.Element.get的简写Ş式?br /> getҎ中只有一个参敎ͼq个参数是؜合参敎ͼ可以是DOM节点的id、也可以是一个Element、或者是一个DOM节点对象{?br /> 代码Q?br /> <div id="EXTJS">aaa</div>
    Ext.onReady(function(){
           var e=new Ext.Element("EXTJS");
           alert(Ext.get("EXTJS"));
           alert(Ext.get(document.getElementById("EXTJS")));
           alert(Ext.get(e));
    }); 三个Ҏ都可以得C个与DOM节点 EXTJS对应的Ext元素?br />
    2、getCmpҎQ获得Extlg?/font>
    getCmpҎ用来获得一个ExtlgQ也是一个已l在面中初始化了的Component或其子类的对象,getCmpҎ其实是Ext.ComponentMgr.getҎ的简写Ş式。getCmpҎ中只有一个参敎ͼ也就是组件的id?br /> 代码Q?br /> <div id="EXTJS">aaa</div>
    Ext.onReady(function(){
           var h=new Ext.Panel({
                id:"h2",
                title:"",
                renderTo:"EXTJS",
                width:300,
                height:200
           });
           Ext.getCmp("h2").setTitle("新的标题");

    });在代码中Q我们用Ext.getCmp("h2").来得到id为h2的组Ӟq调用其setTitleҎ来设|该面板的标题?br />
    3、getDomҎQ获得DOM节点
    getDomҎ能够得到文中的DOM节点Q该Ҏ中包含一个参敎ͼ该参数可以是DOM节点的id、DOM节点对象或DOM节点对应的Ext元素(Element){?br /> 代码Q?br /> <div id="EXTJS">tttt</div>
    Ext.onReady(function(){
           var e=new Ext.Element("EXTJS");
           Ext.getDom("EXTJS");
           Ext.getDom(e);
           Ext.getDom(e.dom);
    });三个语句q回都是同一个DOM节点对象?br />
    4、getBodyҎQ得到文档的body节点元素(Element)?/font>
    该方法直接得到文档中与document.bodyq个DOM节点对应的ExtJS元素QElementQ,实质是把document.body对象装成ExtJS元素对象q回Q该Ҏ不带M参数。比如下面的代码把面板h直接渲染到文的body元素中?br /> Ext.onReady(function(){
           var h=new Ext.Panel({title:"试",width:300,height:200});
           h.render(Ext.getBody());
    });

    5、getDocҎQ获得与document对应的Ext元素(Element)
    getDocҎ实质上就是得到当前html文对象Q也是把document对象装成ExtJS的Element对象q回Q该Ҏ不带M参数Q即Q?br /> getDoc = function(){
        return Ext.get(document);
    }

    seal 2009-11-18 22:13 发表评论
    ]]>
    Ext中初始化配置iconCls的用方??http://www.aygfsteel.com/sealyu/archive/2009/11/18/302852.htmlsealsealWed, 18 Nov 2009 14:02:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/11/18/302852.htmlhttp://www.aygfsteel.com/sealyu/comments/302852.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/11/18/302852.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/302852.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/302852.html

    使用qExtQ?a >http://www.extjs.comQ? 的同志都应该知道Q每一个组ӞComponentQ在初始化的时候,都会有一个配|参敎ͼConfigQ{在Ext2中,基本上所有的lg的构造函数只 接受一个参敎ͼq个参数或者是一个Config Object或都是一个Array of Config Object}Q其中,许多lgQ如MenuQButton都有一个配|选项iconClsQ很明显Q这个是用来配置按钮{的图标的,所以假设我们要初始 化一个ButtonQ我们在JS里这样写Q?br /> var button = new Ext.Button({
            text: "Hello",
            iconCls: "hello-button"
    });

    然后我们再在CSS中写下如下规则:
    .hello-button {
            background: url(images/hello.png) left top no-repeat;
    }

    把JS和CSS文g都正的引入到页面当中后Q我们只能看到按钮上I出来了一个放|图片的位置Q而图片ƈ没有昄出来Q通过使用FirebugQ?a >http://www.getfirebug.comQ? 来查看页面,通过Inspect我们生成的按钮的StyleQ我们发现CSS规则hello-button被Ext原有的CSS规则覆盖掉了。但是官方给 的Sample里是可以用的啊,查看Sample里的CSSQ我发现它比我写的多了一行字Q?importantQ然后,我把我原有的CSS规则修正为:
    .hello-button {
            background: url(images/hello.png) left top no-repeat !important;
    }

    Bingo~q次囄正确的显C在了按钮上?

    当然Q按照官方的APIQ你q有另外一U在按钮上添加图标的ҎQ将button的Config如下讄Q?br /> var button = new Ext.Button({
            text: "Hello",
            icon: "images/public.gif",
            cls: "x-btn-text-icon"

    });

    q样做的坏处在于Q你必须图片的位置写入到JS里,没有表现的部分从JS里脱,如果使用W一U方法的话,可以更容易的更改某个按钮的图标?/p>



    seal 2009-11-18 22:02 发表评论
    ]]>
    ExtJS的xtype列表http://www.aygfsteel.com/sealyu/archive/2009/11/18/302849.htmlsealsealWed, 18 Nov 2009 13:47:00 GMThttp://www.aygfsteel.com/sealyu/archive/2009/11/18/302849.htmlhttp://www.aygfsteel.com/sealyu/comments/302849.htmlhttp://www.aygfsteel.com/sealyu/archive/2009/11/18/302849.html#Feedback0http://www.aygfsteel.com/sealyu/comments/commentRss/302849.htmlhttp://www.aygfsteel.com/sealyu/services/trackbacks/302849.htmlxtype                  Class            

    基本lgQ?/strong>                                                                 

    box                    Ext.BoxComponent                      hҎ属性的lg

    button                Ext.Button                                      按钮

    colorpalette      Ext.ColorPalette                            调色?/p>

    component       Ext.Component                            lg

    container          Ext.Container                                容器

    cycle                 Ext.CycleButton

    dataview          Ext.DataView                                数据昄视图

    datepicker       Ext.DatePicker                              日期选择面板

    editor                Ext.Editor                                       ~辑?/p>

    editorgrid         Ext.grid.EditorGridPanel              可编辑的表格

    grid                   Ext.grid.GridPanel                         表格

    paging              Ext.PagingToolbar                         工具栏中的间?/p>

    panel                Ext.Panel                                        面板

    progress          Ext.ProgressBar                            q度?/p>

    splitbutton        Ext.SplitButton                               可分裂的按钮

    tabpanel           Ext.TabPanel                                 选项面板

    treepanel         Ext.tree.TreePanel                         ?/p>

    viewport           Ext.ViewPort                                  视图

    window             Ext.Window                                   H口

    工具栏组Ӟ

    toolbar              Ext.Toolbar                                    工具?/p>

    tbbutton            Ext.Toolbar.Button                         按钮

    tbfill                   Ext.Toolbar.Fill                               文g

    tbitem               Ext.Toolbar.Item                            工具条项?/p>

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

    tbspacer          Ext.Toolbar.Spacer                       工具栏空?/p>

    tbsplit               Ext.Toolbar.SplitButton                 工具栏分隔按?/p>

    tbtext                Ext.Toolbar.TextItem                     工具栏文本项

    表单及字D늻Ӟ

    form                  Ext.FormPanel Form                     面板

    checkbox         Ext.form.Checkbox checkbox       录入?/p>

    combo             Ext.form.ComboBox combo         选择?/p>

    datefield          Ext.form.DateField                        日期选择?/p>

    field                  Ext.form.Field                                 表单字段

    fieldset            Ext.form.FieldSet                           表单字段l?/p>

    hidden             Ext.form.Hidden                             表单隐藏?/p>

    htmleditor        Ext.form.HtmlEditor html               ~辑?/p>

    numberfield     Ext.form.NumberField                   数字~辑?/p>

    radio                Ext.form.Radio                               单选按?/p>

    textarea           Ext.form.TextArea                          区域文本?/p>

    textfield            Ext.form.TextField                          表单文本?/p>

    timefield           Ext.form.TimeField                         旉录入?/p>

    trigger              Ext.form.TriggerField                      触发录入?/p>

    seal 2009-11-18 21:47 发表评论
    ]]>
    Ext.data专题Q{Q?/title><link>http://www.aygfsteel.com/sealyu/archive/2009/11/17/302707.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Tue, 17 Nov 2009 06:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/sealyu/archive/2009/11/17/302707.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/302707.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2009/11/17/302707.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/302707.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/302707.html</trackback:ping><description><![CDATA[<h3 title="转蝲"><a >Ext.data专题一QExt.data?/a></h3> <div> <p><span style="font-size: large;">Ext.data在命名空间中定义了一pdstore、reader和proxy?/span></p> <p><span style="font-size: large;">Grid和ComboxBox都是以Ext.data为媒介获取数据的Q它包含异步加蝲、类型{换、分늭功能?/span></p> <p><span style="font-size: large;">Ext.data默认支持Array、JSON、XML{数据格式,可以通过 Memory、HTTP、ScriptTag{方式获得这些格式的数据。如果要实现新的协议和新的数据结构,只需要扩展reader和proxy卛_? DWRProxy实C自n的proxy和readerQ让EXT可以直接从DWR获得数据</span></p> </div> <h3 title="转蝲"><a >Ext.data专题二:Ext.data.Connection</a></h3> <p><span style="font-size: large; color: #008080;">Ext.data.Connection 是对Ext.lib.Ajax的封装,它提供了配置使用Ajax的通用方式Q它在内部通过Ext.lib.Ajax实现与后台的异步调用。与底层? Ext.lib.Ajax相比QExt.data. Connection提供了更z的配置方式Q用v来更方便?/span></p> <p><span style="font-size: large; color: #008080;">Ext.data.Connection 主要用于在Ext.data.HttpProxy和Ext.data.ScriptTagProxy中执行与后台交互的Q务,它会从指定的URL获得? 据,q把后台q回的数据交lHttpProxy或ScriptTagProxy处理QExt.data.Connection的用方式如代码清单</span></p> <p><br /> <span style="font-size: large; color: #008080;">var conn = new Ext.data.Connection({</span></p> <p><span style="font-size: large; color: #008080;">    autoAbort: false,</span></p> <p><span style="font-size: large; color: #008080;">    defaultHeaders: {</span></p> <p><span style="font-size: large; color: #008080;">        referer: 'http://localhost:8080/'</span></p> <p><span style="font-size: large; color: #008080;">    },</span></p> <p><span style="font-size: large; color: #008080;">    disableCaching : false,</span></p> <p><span style="font-size: large; color: #008080;">    extraParams : {</span></p> <p><span style="font-size: large; color: #008080;">        name: 'name'</span></p> <p><span style="font-size: large; color: #008080;">    },</span></p> <p><span style="font-size: large; color: #008080;">    method : 'GET',</span></p> <p><span style="font-size: large; color: #008080;">    timeout : 300,</span></p> <p><span style="font-size: large; color: #008080;">    url : '01-01.txt'</span></p> <p><br /> <span style="font-size: large; color: #008080;">});</span></p> <p><span style="font-size: large; color: #008080;">在? Ext.data.Connection之前Q都要像上面q样创徏一个新的Ext.Connection实例。我们可以在构造方法里配置对应的参敎ͼ比如 autoAbort表示链接是否会自动断开、default- Headers参数表示h的默认首部信息、disableCaching参数表示h是否会禁用缓存、extraParams参数代表h的额外参数? method参数表示hҎ、timeout参数表示q接的超时时间、url参数表示h讉K的网址{?/span></p> <p><span style="font-size: large; color: #008080;">在创Zconn之后Q可以调用request()函数发送请求,处理q回的结果,如下面的代码所C?/span></p> <p><br /> </p> <h3 title="转蝲"><a >Ext.data专题三:Ext.data.Record</a></h3> <div> <p><span style="font-size: medium; color: #008080;">Ext.data.Record是一个设定了内部数据cd的对象,它是Ext.data.Store的最基本l成部分。如果把Ext.data.Store看作是一张二l表Q那么它的每一行就对应一个Ext.data. Record实例?/span></p> <p><span style="font-size: medium; color: #008080;">Ext.data.Record的主要功能是保存数据Qƈ且在内部数据发生改变时记录修改的状态,它还可以保留修改之前的原始倹{?/span></p> <p><span style="font-size: medium; color: #008080;">我们使用Ext.data.Record旉常都是由create()函数开始,首先用create()函数创徏一个自定义的RecordcdQ如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">var PersonRecord = Ext.data.Record.create([</span></p> <p><span style="font-size: medium; color: #008080;">    {name: 'name', type: 'string'},</span></p> <p><span style="font-size: medium; color: #008080;">    {name: 'sex', type: 'int'}</span></p> <p><span style="font-size: medium; color: #008080;">]);</span></p> <p><span style="font-size: medium; color: #008080;">PersonRecord是我们定义的新cdQ包含字W串cd的name和整数类型的sex两个属性,然后我们使用new关键字创建PersonRecord的实例,如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">var boy = new PersonRecord({</span></p> <p><span style="font-size: medium; color: #008080;">    name: 'boy',</span></p> <p><span style="font-size: medium; color: #008080;">    sex: 0</span></p> <p><span style="font-size: medium; color: #008080;">});</span></p> <p><span style="font-size: medium; color: #008080;">创徏对象Ӟ可以直接通过构造方法ؓ对象赋予初始|?boy'赋值给nameQ?赋值给sex?/span></p> <p><span style="font-size: medium; color: #008080;">现在Q我们得CPersonRecord的实例boyQ如何才能得到它的属性呢Q以下三U方式都可以获得boy中name属性的数据Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">alert(boy.data.name);</span></p> <p><span style="font-size: medium; color: #008080;">alert(boy.data['name']);</span></p> <p><span style="font-size: medium; color: #008080;">alert(boy.get('name'));</span></p> <p><span style="font-size: medium; color: #008080;">q里涉及 Ext.data.Record的data属性,q是定义在Ext.data.Record中的一个公共属性,用于保存当前record对象的所有数据? 它是一个JSON对象Q可以直接从它里面获得需要的数据。可以通过Ext.data.Record的get()函数方便Cdata属性中获得指定的属? 倹{?/span></p> <p><span style="font-size: medium; color: #008080;">如果我们需要修改boy中的数据Q请不要使用以下方式直接操作dataQ如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">    boy.data.name = 'boy name';</span></p> <p><span style="font-size: medium; color: #008080;">    boy.data['name'] = 'boy name';</span></p> <p><span style="font-size: medium; color: #008080;">而应该用set()函数Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">    boy.set('name', 'body name');</span></p> <p><span style="font-size: medium; color: #008080;">set()函数会判断属性值是否发生了改变Q如果改变了Q就要将当前对象的dirty属性设|ؓtrueQƈ修改之前的原始值放入modified对象中,供其他函C用。如果直接操作data中的|record无法记录属性数据的修改情况?/span></p> <p><span style="font-size: medium; color: #008080;">Record的属性数据被修改后,我们可以执行如下几种操作?/span></p> <p><span style="font-size: medium; color: #008080;">q   commit()Q提交)Q这个函数的效果是设|dirty为falseQƈ删除modified中保存的原始数据?/span></p> <p><span style="font-size: medium; color: #008080;">q   reject()Q撤销Q:q个函数的效果是data中已l修改了的属性值都恢复成modified中保存的原始数据Q然后设|dirty为falseQƈ删除保存原始数据的modified对象?/span></p> <p><span style="font-size: medium; color: #008080;">q   getChanges()获得修改的部分:q个函数会把data中经q修改的属性和数据攑֜一个JSON对象里ƈq回。例如上例中QgetChanges()q回的结果是{name:’body name’}?/span></p> <p><span style="font-size: medium; color: #008080;">q   我们q可以调用isModified()判断当前record中的数据是否被修攏V?/span></p> <p><span style="font-size: medium; color: #008080;">      Ext.data.Recordq提供了用于复制record实例的函数copy()?/span></p> <p><span style="font-size: medium; color: #008080;">var copyBoy = boy.copy();</span></p> <p><span style="font-size: medium; color: #008080;">q样我们得Cboy的一个副本,它里面包含了boy的data数据Q但copy()函数不会复制dirty和modified{额外的属性倹{?/span></p> <p><br /> </p> <h3 title="转蝲"><a >Ext.data专题四:Ext.data.Store</a></h3> <div> <p><span style="font-size: medium; color: #008080;">Ext.data.Store是EXT中用来进行数据交换和数据交互的标准中间gQ无论是Gridq是ComboBoxQ都是通过它实现数据读取、类型{换、排序分和搜烦{操作的?/span></p> <p><span style="font-size: medium; color: #008080;">Ext.data.Store中有一个Ext.data.Record数组Q所有数据都存放在这些Ext.data. Record实例中,为后面的d和修Ҏ作做准备?/span></p> <p><strong><span style="font-size: medium; color: #008080;">一、Ext.data.Store基本应用</span></strong></p> <p><span style="font-size: medium; color: #008080;">在用之前,首先要创Z个Ext.data.Store的实例,如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">var data = [</span></p> <p><span style="font-size: medium; color: #008080;">    ['boy', 0],</span></p> <p><span style="font-size: medium; color: #008080;">    ['girl', 1]</span></p> <p><span style="font-size: medium; color: #008080;">];</span></p> <p><span style="font-size: medium; color: #008080;">var store = new Ext.data.Store({</span></p> <p><span style="font-size: medium; color: #008080;">    proxy: new Ext.data.MemoryProxy(data),</span></p> <p><span style="font-size: medium; color: #008080;">    reader: new Ext.data.ArrayReader({}, PersonRecord)</span></p> <p><span style="font-size: medium; color: #008080;">});</span></p> <p><span style="font-size: medium; color: #008080;">store.load();</span></p> <p><span style="font-size: medium; color: #008080;">每个store最需要两个组件的支持Q分别是proxy和readerQproxy用于从某个途径d原始数据Qreader用于原始数据{换成Record实例?/span></p> <p><span style="font-size: medium; color: #008080;">q里我们使用的是 Ext.data.MemoryProxy和Ext.data.ArrayReaderQ将data数组中的数据转换成对应的几个 PersonRecord实例Q然后放入store中。store创徏完毕之后Q执行store.load()实现q个转换q程?/span></p> <p><span style="font-size: medium; color: #008080;">l过转换之后Qstore里的数据可以提供给Grid或ComboBox使用了,q就是Ext.data. Store的最基本用法?/span></p> <p><strong><span style="font-size: medium; color: #008080;">二、Ext.data.StoreҎ据进行排?/span></strong></p> <p><span style="font-size: medium; color: #008080;">Ext.data.Store提供了一pd属性和函数Q利用它们对数据q行排序操作?/span></p> <p><span style="font-size: medium; color: #008080;">可以在创建Ext.data.Store时用sortInfo参数指定排序的字D和排序方式Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">var store = new Ext.data.Store({</span></p> <p><span style="font-size: medium; color: #008080;">    proxy: new Ext.data.MemoryProxy(data),</span></p> <p><span style="font-size: medium; color: #008080;">    reader: new Ext.data.ArrayReader({}, PersonRecord),</span></p> <p><span style="font-size: medium; color: #008080;">    sortInfo: {field: 'name', direction: 'DESC'}</span></p> <p><span style="font-size: medium; color: #008080;">});</span></p> <p><span style="font-size: medium; color: #008080;">q样Q在store加蝲数据之后Q就会自动根据name字段q行降序排列。对store使用store.setDefaultSort('name','DESC');也会辑ֈ同样效果?/span></p> <p><span style="font-size: medium; color: #008080;">也可以在M时候调用sort()函数Q比如store.sort('name', 'DESC');Q对store中的数据q行排序?/span></p> <p><span style="font-size: medium; color: #008080;">如果我们希望获得store的排序信息,可以调用getSortState()函数Q返回的是类似{field: "name", direction: " DESC"}的JSON对象?/span></p> <p><span style="font-size: medium; color: #008080;">与排序相关的参数q有 remoteSortQ这个参数是用来实现后台排序功能的。当讄为remoteSort:trueӞstore会在向后台请求数据时自动加入sort 和dir两个参数Q分别对应排序的字段和排序的方式Q由后台获取q处理这两个参数Q在后台Ҏ需数据q行排序操作。remoteSort:true也会? 致每ơ执行sort()旉要去后台重新加蝲数据Q而不能只Ҏ地数据进行排序?/span></p> <p><strong><span style="font-size: medium; color: #008080;">三、Ext.data.Store加蝲及显C数?/span></strong></p> <p><span style="font-size: medium; color: #008080;">store创徏好后Q需要调用load()函数加蝲数据Q加载成功后才能对store中的数据q行操作。load()调用的完整过E如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">store.load({</span></p> <p><span style="font-size: medium; color: #008080;">    params: {start:0,limit:20},</span></p> <p><span style="font-size: medium; color: #008080;">    callback: function(records, options, success){</span></p> <p><span style="font-size: medium; color: #008080;">        Ext.Msg.alert('info', '加蝲完毕');</span></p> <p><span style="font-size: medium; color: #008080;">    },</span></p> <p><span style="font-size: medium; color: #008080;">    scope: store,</span></p> <p><span style="font-size: medium; color: #008080;">    add: true</span></p> <p><span style="font-size: medium; color: #008080;">});</span></p> <p><span style="font-size: medium; color: #008080;">  params是在store加蝲时发送的附加参数?/span></p> <p><span style="font-size: medium; color: #008080;">  callback是加载完毕时执行的回调函敎ͼ它包?个参敎ͼrecords参数表示获得的数据,options表示执行load()时传递的参数Qsuccess表示是否加蝲成功?/span></p> <p><span style="font-size: medium; color: #008080;">Scope用来指定回调函数执行时的作用域?/span></p> <p><span style="font-size: medium; color: #008080;">  Add为trueӞload()得到的数据会d在原来的store数据的末,否则会先清除之前的数据,再将得到的数据添加到store中?/span></p> <p><span style="font-size: medium; color: #008080;">一般来_Z对store中的数据q行初始化,load()函数只需要执行一ơ。如果用params参数指定了需要用的参数Q以后再ơ执行reload()重新加蝲数据Ӟstore会自动用上ơload()中包含的params参数内容?/span></p> <p><span style="font-size: medium; color: #008080;">如果有一些需要固定传递的参数Q也可以使用baseParams参数执行Q它是一个JSON对象Q里面的数据会作为参数发送给后台处理Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">store.baseParams.start = 0;</span></p> <p><span style="font-size: medium; color: #008080;">store.baseParams.limit = 20;</span></p> <p><span style="font-size: medium; color: #008080;">为store加蝲数据之后Q有时不需要把所有数据都昄出来Q这时可以用函数filter和filterBy对store中的数据q行qoQ只昄W合条g的部分,如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">filter( String field, String/RegExp value, [Boolean anyMatch], <br /> [Boolean caseSensitive] ) : void</span></p> <p><span style="font-size: medium; color: #008080;">filter()函数的用法与之前谈到的find()怼Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">store.filter('name', 'boy');</span></p> <p><span style="font-size: medium; color: #008080;">对应的filterBy()与findBy()cMQ也可以在自定义的函C实现各种复杂判断Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">store.filterBy(function(record) {</span></p> <p><span style="font-size: medium; color: #008080;">    return record.get('name') == 'girl' && record.get('sex') == 1;</span></p> <p><span style="font-size: medium; color: #008080;">});</span></p> <p><span style="font-size: medium; color: #008080;">如果惛_消过滤ƈ昄所有数据,那么可以调用clearFilter()函数Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">store.clearFilter();</span></p> <p><span style="font-size: medium; color: #008080;">如果想知道store上是否设|了qo器,可以通过isFiltered()函数q行判断?/span></p> <p><strong><span style="font-size: medium; color: #008080;">四、Ext.data.Store其他功能</span></strong></p> <p><span style="font-size: medium; color: #008080;">除了上面提到的数据获取、排序、更新、显C等功能外,storeq提供了其他一些功能函数?/span></p> <p><span style="font-size: medium; color: #008080;">collect( String dataIndex, [Boolean allowNull], [Boolean bypassFilter] ) : Array</span></p> <p><span style="font-size: medium; color: #008080;">collect函数获得 指定的dataIndex对应的那一列的数据Q当allowNull参数为trueӞq回的结果中可能会包含null、undefined或空字符Ԍ 否则collect函数会自动将q些I数据过滤掉。当bypassFilter参数为trueӞcollect的结果不会受查询条g的媄响,无论查询? 件是什么都会忽略掉Q返回的信息是所有的数据Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">alert(store.collect('name'));</span></p> <p><span style="font-size: medium; color: #008080;">q样会获得所有name列的|CZ中返回的是包含了'boy'?girl'的数l?/span></p> <p><span style="font-size: medium; color: #008080;">getTotalCount()用于在翻|获得后台传递过来的数据L。如果没有设|翻,get- TotalCount()的结果与getCount()相同Q都是返回当前的数据LQ如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">alert(store.getTotalCount());</span></p> <p><span style="font-size: medium; color: #008080;">indexOf(Ext.data.Record record)和indexOfId(String id)函数Ҏrecord或record的id获得record对应的行P如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">alert(store.indexOf(store.getAt(1)));</span></p> <p><span style="font-size: medium; color: #008080;">alert(store.indexOfId(1001));</span></p> <p><span style="font-size: medium; color: #008080;">loadData(object data, [Boolean append])从本地JavaScript变量中读取数据,append为trueӞ读取的数据附加到原数据后,否则执行整体更新Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">store.loadData(data, true);</span></p> <p><span style="font-size: medium; color: #008080;">Sum(String property, Number start, Number end):Number用于计算某一个列从start到end的dQ如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008080;">alert(store.sum('sex'));</span></p> </div> </div> <h3 title="转蝲"><a >Ext.data专题五:常用proxy之MemoryProxy</a></h3> <div> <p><span style="font-size: medium; color: #008000;">MemoryProxy只能从JavaScript对象获得数据Q可以直接把数组Q或JSON和XML格式的数据交l它处理Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008000;">var proxy = new Ext.data.MemoryProxy([<br />     ['id1','name1','descn1'],<br />     ['id2','name2','descn2']<br /> ]);</span></p> <p><span style="font-size: medium; color: #008000;">HttpProxy使用HTTP协议Q通过Ajaxd台取数据Q构造它旉要设|?/span><a ><span style="font-size: medium; color: #008000;">url:'xxx.jsp'</span></a><span style="font-size: medium; color: #008000;">参数。这里的url可以替换成Q何一个合法的|址Q这样HttpProxy才知道去哪里获取数据Q如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008000;">var proxy = new Ext.data.HttpProxy({url:'xxx.jsp'});               </span></p> <p><span style="font-size: medium; color: #008000;">后台需要返回EXT所需要的JSON格式的数据,下面的内容就是后C用JSP的一个范例,如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008000;">response.setContentType("application/x-json");</span></p> <p><span style="font-size: medium; color: #008000;">Writer out = response.getWriter();</span></p> <p><span style="font-size: medium; color: #008000;">out.print("[" +</span></p> <p><span style="font-size: medium; color: #008000;">        "['id1','name1','descn1']" +</span></p> <p><span style="font-size: medium; color: #008000;">        "['id2','name2','descn2']" +</span></p> <p><span style="font-size: medium; color: #008000;">    "]");               </span></p> <p><span style="font-size: medium; color: #008000;">h意,q里的HttpProxy不支持跨域,它只能从同一域中获得数据。如果想跨域Q请参考下面的ScriptTagProxy?/span></p> <p><strong><span style="font-size: medium; color: #008000;">常用proxy之ScriptTagProxy</span></strong></p> <p><span style="font-size: medium; color: #008000;">ScriptTagProxy的用法几乎和HttpProxy一P如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008000;">var proxy = new Ext.data.ScriptTagProxy({url:'xxx.jsp'});               </span></p> <p><span style="font-size: medium; color: #008000;">从这里也看不出来它是如何支持跨域的,我们q需要在后台q行相应的处理,如下面的代码所C?/span></p> <p><span style="font-size: medium; color: #008000;">String cb = request.getParameter("callback");</span></p> <p><span style="font-size: medium; color: #008000;">response.setContentType("text/javascript");</span></p> <p><span style="font-size: medium; color: #008000;">Writer out = response.getWriter();</span></p> <p><span style="font-size: medium; color: #008000;">out.write(cb + "(");</span></p> <p><span style="font-size: medium; color: #008000;">out.print("[" +</span></p> <p><span style="font-size: medium; color: #008000;">        "['id1','name1','descn1']" +</span></p> <p><span style="font-size: medium; color: #008000;">        "['id2','name2','descn2']" +</span></p> <p><span style="font-size: medium; color: #008000;">    "]");</span></p> <p><span style="font-size: medium; color: #008000;">out.write(");");</span></p> <p><span style="font-size: medium; color: #008000;">其中的关键就在于从请求中? 得的callback参数Q这个参数叫做回调函数。ScriptTag- Proxy会在当前的HTML面里添加一?lt;script type="text/javascript"src="xxx.jsp"> </script>标签Q然后把后台q回的内Ҏ加到q个标签中,q样可以解册域访问数据的问题。ؓ了让后台q回的内容可以在动态生成的 标签中运行,EXT会生成一个名为callback的回调函敎ͼq把回调函数的名UC递给后台Q由后台生成callback(data)形式的响应内容, 然后q回l前台自动运行?/span></p> <p><span style="font-size: medium; color: #008000;">虽然上述处理q程比较隄解,但是我们只需要了解ScriptTagProxy的用法就_了。如果还惌一步了解ScriptTagProxy的运行过E,可以使用Firebug查看动态生成的HTML以及响应的JSON内容?/span></p> <p><span style="font-size: medium; color: #008000;">最后我们来分析一下EXT的API文中提供的CZQ这D后C码会自动判断h的类型,q回支持ScriptTagProxy或HttpProxy的数据,如代码清?0-2所C?/span></p> <p><span style="font-size: medium; color: #008000;">代码清单 在后台同时支持HttpProxy和ScriptTagProxy</span></p> <p><span style="font-size: medium; color: #008000;">boolean scriptTag = false;</span></p> <p><span style="font-size: medium; color: #008000;">String cb = request.getParameter("callback");</span></p> <p><span style="font-size: medium; color: #008000;">if (cb != null) {</span></p> <p><span style="font-size: medium; color: #008000;">    scriptTag = true;</span></p> <p><span style="font-size: medium; color: #008000;">    response.setContentType("text/javascript");</span></p> <p><span style="font-size: medium; color: #008000;">} else {</span></p> <p><span style="font-size: medium; color: #008000;">    response.setContentType("application/x-json");</span></p> <p><span style="font-size: medium; color: #008000;">}</span></p> <p><span style="font-size: medium; color: #008000;">Writer out = response.getWriter();</span></p> <p><span style="font-size: medium; color: #008000;">if (scriptTag) {</span></p> <p><span style="font-size: medium; color: #008000;">    out.write(cb + "(");</span></p> <p><span style="font-size: medium; color: #008000;">}</span></p> <p><span style="font-size: medium; color: #008000;">out.print(dataBlock.toJsonString());</span></p> <p><span style="font-size: medium; color: #008000;">if (scriptTag) {</span></p> <p><span style="font-size: medium; color: #008000;">    out.write(");");</span></p> <p><span style="font-size: medium; color: #008000;">}               </span></p> <p><span style="font-size: medium; color: #008000;">代码中通过判断h中是否包含callback参数来决定返回何U数据类型。如果包含,p回ScriptTagProxy需要的数据Q否则,当作HttpProxy处理?/span></p> </div> <img src ="http://www.aygfsteel.com/sealyu/aggbug/302707.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2009-11-17 14:57 <a href="http://www.aygfsteel.com/sealyu/archive/2009/11/17/302707.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ExtJS 开发ȝ Q{Q?/title><link>http://www.aygfsteel.com/sealyu/archive/2009/11/15/302412.html</link><dc:creator>seal</dc:creator><author>seal</author><pubDate>Sun, 15 Nov 2009 06:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/sealyu/archive/2009/11/15/302412.html</guid><wfw:comment>http://www.aygfsteel.com/sealyu/comments/302412.html</wfw:comment><comments>http://www.aygfsteel.com/sealyu/archive/2009/11/15/302412.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sealyu/comments/commentRss/302412.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sealyu/services/trackbacks/302412.html</trackback:ping><description><![CDATA[<p>1. <strong>ExtJS的定位是RIAQ和Prototype、jQuery{类库的定位不同</strong>。用ExtJS做开发,是意味着以客L开发ؓ主,不然׃叫RIA框架了,而Prototype、jQuery{只是辅助性的客户端框Ӟ和ExtJS不在同一条v跑先上。如果一定要和其它的框架做比较的话,应该?a target="_blank">Isomorphic SmartClient</a>?a target="_blank">Backbase Enterprise Ajax</a>之类的框架做比较Q当Ӟ和他们相比,ExtJSq是有很大的优势的?/p> <p>2. <strong>使用ExtJS旉要解军_何服务端通信的问?/strong>。由于ExtJS只是一个客L的框Ӟ和服务端技术没有关p,也就没有相应的服务端的适配层,因此客户端如果要用ExtJSQ则必须提供它需要的数据l构。ExtJS主要通过q几U方式和服务端进行通信Q?</p> <ul> <li> <strong>Ext.Ajax.request</strong> 做普通的异步hQ服务端可以Ҏ实际情况q回JSON形式数据或者HTML片段Q?</li> <li> <strong>Ext.tree.TreeLoader</strong> 加蝲树Şl构Q服务端必须q回JSON形式数据Q而且要符合Ext.tree.TreeNode的配|要求,否则自己做{换; </li> <li> <strong>Ext.data.Store及其zc?/strong> 加蝲表格形式的数据,服务端可以根据实际情况返回JSON形式数据或者XML形式数据Q如果没有特D要求,推荐q回JSON格式的数据; </li> <li> <strong>Ext.Element.update</strong> 局部更斎ͼq个Ҏ最总还是要调用Ext.Ajax.requestҎQ之所以把它单独列出来Q是因ؓq种方式比较Ҏ被忽视,但是在某些情况下q是? 有用的,比如调用Ext.Panel.body.update()Ҏ个Ext.Panel的内容进行局部更斎ͼ如果使用q种方式Q那么服务端只能相应? q回HTML片段了; </li> </ul> <p>3. <strong>使用ExtJS时的注意事项</strong>。ExtJS和其它的辅助性类?Prototype、jQuery{?相比昑־非常庞大Q让很多很多初学者望而却步。经q近一q的学和用,对于ExtJS的用,我ȝ了一下几个注意事: </p> <ul> <li> <strong>量使用ExtJS的方a</strong>?ExtJS提供了很多有用的ҎQ解军_LJavaScript常见的开发Q务,常见的有查询HTMLDomQ创建HTML元素QؓHTML元素注册事g响应函数{,q些大可以全部用ExtJS提供的方法,使自׃码构ZExtJS之上QD几个例子Q? <ul> <li>查询ID为container的DIV下所有的checkboxQ可以用:<span style="color: #ff8000; font-family: Courier New;">Ext.fly(‘container’).select(‘input[type=checkbox]’);</span> </li> <li>在ID为container的DIV内创Z个按钮,可以使用Q?span style="color: #ff8000; font-family: Courier New;">Ext.fly(‘container’).createChild({ tag: ‘input’, type: ‘button’});</span> </li> <li>为ID为container的DIV的click事g注册处理函数Q用:<span style="color: #ff8000; font-family: Courier New;">Ext.fly(‘container’).on(‘click’, handlerFn, scope);</span> </li> </ul> </li> <li> <strong>ExtJS的自定义事g很好?/strong>Q可以实C对多的通知Q而且M自定义事仉可以中途停止,只要有一个处理函数返回false?</li> <li> <strong>Store合ƈ成一个文?/strong> 用ExtJS昄数据Q自然就需要用到Ext.data.Store及其z出来的类Q可以考虑所有的Store合ƈC个文Ӟq样寚w用有很大的帮助?</li> <li> <strong>脚本文g理</strong> 可能的每个模块做成一个类Q一个类一个文ӞcM与Java或C# 的文件处理方法,每个文g注明其作用,依赖的文件等Q如果太多的话可以考虑写一个配|文Ӟ通过读配|文件来输出脚本到客L?</li> <li> <strong>调试和部|分别加载Debug和Release版本的脚?/strong> ExtJS附带的例子中没有使用完整Debug版本的例子,所以很多h找不到完整的Debug版本的引用顺序,通过对Source文g夹下的ext.jsb文gq行分析Q就可以得到正确的加载顺序,如下Q? <ul> <li>Debug <ol> <li>/ext-path/source/core/ext.js </li> <li>/ext-path/source/adapter/ext-base.js </li> <li>/ext-path/ext-all-debug.js </li> </ol> </li> <li>Release <ol> <li>/ext-path/adapter/ext/ext-base.js </li> <li>/ext-path/ext-all.js </li> </ol> </li> </ul> </li> <li> <strong>对Scriptq行压羃</strong> 寚w目中有大量的JavaScript的话Q对其进行压~是很有必要的,q里我推荐的是ExtJS的论坛提供的<a target="_blank">JS Builder</a>Q可以通过配置文g来对Script和CSSq行压羃Q据说ExtJS是用这个工兯行压~的Q不q有一个缺点,是不支持UTF-8~码?</li> </ul> <p>4. <strong>ExtJS的优点和~点ȝ</strong>。经q近一q的试QExtJS的优~点ȝ如下Q?</p> <ul> <li>优点 <ul> <li> <strong>一致的cd</strong> q点?.1版本时还不是很完善,但是C2.0以后QExtJS内部l过了翻天覆地的变化Q特别是UIlgQ有l一的基c,lh的感觉很像是一个运行在览器上的运行时框架Q这一点只有在对ExtJS熟练了之后才能体会到?</li> <li> <strong>托管面呈现</strong> ExtJS在发展到2.0之后Q不仅UIcd一致了Q而且渲染方式也是l一的,用官方的话说Q是Managed RenderingQ这一点得UI的扩展也比较一_有利于以后的l护与发展?</li> <li> <strong>相对丰富的文和CZ</strong> 毫无疑问Q刚刚接触到ExtJS的h多数都是被它附带的例子和开发文吸引过ȝQ它的文做的确实不错?</li> <li> <strong>华丽而成熟的界面</strong> ExtJS?.0之后的界面真的是没得_不仅华丽Q而且相对很成熟?</li> </ul> </li> <li>~点 <ul> <li> <strong>没有合适的开发利?/strong> 毫无疑问Q一个好的开发工具可以大大的提高~码的速度Q但是对于ExtJSQ始l没有一个完的开发工P可以推荐的有<a target="_blank">Aptana Studio</a>Q?<a target="_blank">Spket IDE</a>Q和<a target="_blank">Spket 提供的提C文?/a>Q但是都是各有优~点Q都不完,只能一边看SDK一边写代码?</li> <li> <strong>没有界面设计工具</strong> 虽然有h提供了一?a target="_blank">在线的界面设计工?/a>Q但是和Visual Studio提供的ASP.Net设计工具来说Q真的可以说是天壤之别。因此,只能一辚w览,一边写代码?</li> <li> <strong>文档不全</strong> 虽然ExtJS提供的文档很丰富Q但是还是跟不上源代码的更新速度Q所以,l常要通过看源代码Q调试才能真正解决问题?</li> <li> <strong>不能~译</strong> q一点可以说是JavaScript的缺点(如果能编译,׃叫JavaScript了)Q在实际的开发中Q经怼敲错一些代码,比如大小写错误等Q不能通过~译得到反馈Q只能在q行时排错,D开发的效率比较低下?</li> </ul> </li> </ul> <p>5. <strong>使用ExtJS做应用的一些徏?/strong>。多Ch认ؓExtJS的脚本体U很大,不适合攑ֈ互联|上Q对于这一点,有如下徏议: </p> <ol> <li>部vC联网上的Web应用一定要加蝲Release版本的ExtJS </li> <li>可以考虑只加载必ȝlgQbuild目录下脚本文仉是压~过的,如果目中用到的ExtJS的组件不是很多,可以只加载用到的 </li> <li>考虑使用IIS的文件压~功?</li> <li>使用Google的GearsQ把所有的静态文件做客户端缓?</li> <li>使用ADOBE的AIRQ把脚本打包到客Lq行 </li> </ol> <p>ȝ来说QExtJS是一个不错的框架Q它陪伴我走q了_ֽ?008Q也许在未来?009Q我会{向其它的RIA技术,但是我至会l箋xExtJSQ同时也希望q个框架能够强的生存下厅R?/p> <p>PSQ共享一些学习资料:</p> <ul> <li> <a target="_blank">ExtJS 2.0 ?/a> Q推荐反复阅读,l细体会Q?</li> <li> <a target="_blank">ExtJS的用h展合?/a> Q推荐常ȝ看) </li> <li> <a target="_blank">如何用ExtJS构徏大型应用</a> Q可以说是做ExtJS开发的指导思想Q?</li> <li> <a target="_blank">ExtJS 2.0 cd的脑?/a> Q可以加深对ExtJScd的承关pȝ理解Q?/li> </ul> <img src ="http://www.aygfsteel.com/sealyu/aggbug/302412.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sealyu/" target="_blank">seal</a> 2009-11-15 14:22 <a href="http://www.aygfsteel.com/sealyu/archive/2009/11/15/302412.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ӷ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">տ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ƽ</a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ӣ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˫Ѽɽ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">۽</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ع</a>| <a href="http://" target="_blank">¬</a>| <a href="http://" target="_blank">ͺ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̶</a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">֣</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">Ͼ</a>| <a href="http://" target="_blank">ˮ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>