PDA

View Full Version : Define new class, create object of that type. Just to memorize syntax



user14
21 Aug 2012, 11:29 AM
In Java we create class:

class MyClass{

String name; // <-- instance variable

MyClass(String name) { // <-- constructor
this.name=name;
}

void DisplayName(){ // <-- any class method
System.out.println(name);
}
}

And now we can create object :

MyClass myClassVar = new MyClass("John");
After object created , we can invoke method on it:

myClassVar.DisplayName();

PLEASE: Show me the same in ExtJS !
I mean define class and create var ( instance of that type)

scottmartin
21 Aug 2012, 2:47 PM
Have a look at the following:
http://www.sencha.com/learn/sencha-class-system/
http://www.sencha.com/conference/session/the-sencha-class-system

Regards,
Scott.

slemmon
24 Aug 2012, 10:05 AM
Ext.define('MyClass', {
name: undefined
, displayName: function () {
alert(this.name)
}
});

var self = Ext.create('MyClass', { name: 'John' });

self.displayName();