~crf-team/crf-irp/crf-irp

« back to all changes in this revision

Viewing changes to WebContent/js/extjs-2/examples/remoteload/ComponentLoader.js

  • Committer: Thomas
  • Date: 2010-03-10 23:55:46 UTC
  • Revision ID: thomas@daisybox-port-20100310235546-23635dk6x5asb1ca
Upgrade ExtJs 3.1.1
Upgrade Spring 3.0.1 + dependencies
Change Jawr JS post processor : YUI
Upgrade to last build of dwr 3 trunk 69 revision 3019(after build 116), upgrade jawr-dwr plugin 1.4 unofficiale from jose noheda, Jawr 3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Ext JS Library 2.3.0
3
 
 * Copyright(c) 2006-2009, Ext JS, LLC.
4
 
 * licensing@extjs.com
5
 
 * 
6
 
 * http://extjs.com/license
7
 
 */
8
 
 
9
 
Ext.namespace('Ext.ux');
10
 
 
11
 
/**
12
 
 * @class Ext.ux.ComponentLoader
13
 
 * Provides an easy way to load components dynamically. If you provide these components
14
 
 * with an id you can use Ext.ComponentMgr's onAvailable function to manipulate the components
15
 
 * as they are added.
16
 
 * @singleton
17
 
 */
18
 
Ext.ux.ComponentLoader = function() {
19
 
        var cm = Ext.ComponentMgr;                      
20
 
        return {
21
 
                /*
22
 
                 *  
23
 
                 */
24
 
                root: 'components',
25
 
                /*
26
 
                 * Load components from a server resource, config options include anything available in @link Ext.data.Connect#request
27
 
                 * Note: Always uses the connection of Ext.Ajax 
28
 
                 */
29
 
                load : function(config) {
30
 
                        Ext.apply(config, {
31
 
                                callback: this.onLoad.createDelegate(this, [config.container], true),
32
 
                                scope: this
33
 
                        });     
34
 
                        if (config.container) {
35
 
                                Ext.apply(config.params, {
36
 
                                        container: config.container
37
 
                                });
38
 
                        }
39
 
                        Ext.Ajax.request(config);
40
 
                },
41
 
                // private
42
 
                onLoad : function(opts, success, response, ct) {                        
43
 
                        var config = Ext.decode(response.responseText);
44
 
                        if (config.success) {
45
 
                                var comps = config[this.root];                          
46
 
                                // loop over each component returned.                           
47
 
                                for (var i = 0; i < comps.length; i++) {
48
 
                                        var c = comps[i];
49
 
                                        // special case of viewport, no container to add to
50
 
                                        if (c.xtype && c.xtype === 'viewport') {
51
 
                                                cm.create(c);
52
 
                                        // add to container
53
 
                                        } else {
54
 
                                                var ct = c.container || ct;
55
 
                                                Ext.getCmp(ct).add(c);
56
 
                                                Ext.getCmp(ct).doLayout();
57
 
                                        }
58
 
                                }
59
 
                                
60
 
                        } else {
61
 
                                this.onFailure();
62
 
                        }
63
 
                },
64
 
                onFailure: function() {
65
 
                        Ext.Msg.alert('Load failed.');
66
 
                }
67
 
        };
68
 
}();
 
 
b'\\ No newline at end of file'