Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    3
    tryanDLS is on a distinguished road

      0  

    Default Extending MixedColllection

    Extending MixedColllection


    I'm migrating one of my custom collection objects to take advantage of MixedCollection. The following works, but isn't the most elegant solution:

    1) output has to be defined at the object level, rather than being passed as an arg or returned from each/eachKey.
    2) requires 2 methods to accomplish a function (e.g. toString/_toString). I tried to inline the _toString as the 1st arg to eachKey, but couldn't get it to work.

    Any thoughts on making this cleaner?


    Code:
    SoapArgs = function() {
    	SoapArgs.superclass.constructor.call(this, true);
    }
    YAHOO.extendX(SoapArgs, YAHOO.ext.util.MixedCollection, {
    	output: '',
    
    	toXml: function() {
    		this.output = '';
    		this.eachKey(this._serialize, this);
    		return this.output;
    	},
    
    	toString: function() {
    		this.output = '';
    		this.eachKey(this._toString, this);
    		return this.output;
    	},
    
    	/* @private */
    	_toString: function(key, item) {
    		this.output += (this.output.length > 0) ? ',' : '';
    		this.output += key + ':' + item;
    
    	},
    
    	/* @private */
    	_serialize: function(key, item) {
    		// util.serialize recursively processes item to dump its data
    		this.output += '<' + key + '>' + util.serialize(item) + '</' + key + '>';
    	}
    });
    
    // test
    var args = new SoapArgs();
    args.add('ntid', 'jdoe');
    args.add('domain', 'yahoo.com');
    args.add('complexObj', {a:0, b:'1', c:true, d:null});
    
    var xml = args.toXml();
    // returns "<ntid>jdoe</ntid><domain>yahoo.com</domain><complexObj><a>0</a>1<c>true</c><d></d></complexObj>"
    
    var txt = args.toString();
    // returns "ntid:jdoe,domain:yahoo.com,complexObj:[object Object]"

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    You could just use a closure:

    Code:
    toXml: function() {
          var output = '';
          this.eachKey(function(key, value){
              output += '<' + key + '>' + util.serialize(value) + '</' + key + '>';
          });
          return output;
       }

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    3
    tryanDLS is on a distinguished road

      0  

    Default


    Yeah, that was my thought too. I couldn't get it to work - it just disappeared off into neverland in the debugger. I gave up and went with the 2 step solution. Just retried your way and it worked - must of been a typo - too much time spent looking at the code I guess

  4. #4
    Ext User
    Join Date
    Mar 2007
    Posts
    321
    Vote Rating
    0
    jbowman is on a distinguished road

      0  

    Default


    I've found that using try and catch when you're deep into javascript running javascript helps a lot. I just use YAHOO.log and shoot error messages to that, you could also just alert.

Similar Threads

  1. extending Ext classes
    By sean in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 13 Mar 2007, 4:56 AM
  2. Extending BasicDialog
    By moraes in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 20 Dec 2006, 9:15 PM
  3. Extending MixedColllection
    By tryanDLS in forum Community Discussion
    Replies: 0
    Last Post: 14 Nov 2006, 10:11 AM
  4. Extending
    By JohnT in forum Community Discussion
    Replies: 5
    Last Post: 23 Oct 2006, 7:42 PM
  5. Extending a Forum with YUI
    By xux in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 4 Oct 2006, 2:43 AM

Thread Participants: 2