ExtJS Classes By Aaron Conran. Creating Classes Creating classes in JavaScript is easy as creating a constructor function and using the new keyword when.

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Constructors Method Overriding & Overloading Encapsulation.
Advertisements

Python Objects and Classes
Inheritance // A simple class hierarchy. // A class for two-dimensional objects. class TwoDShape { double width; double height; void showDim() { System.out.println("Width.
Java Programming 2 Dr. Priti Srinivas Sajja Introductory concepts of java programming as specified in PGDCA 203:Object Technology, S P University.
OOP: Inheritance By: Lamiaa Said.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
1 Lecture 3 Inheritance. 2 A class that is inherited is called superclass The class that inherits is called subclass A subclass is a specialized version.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Inheritance. In this chapter, we will cover: The concept of inheritance Extending classes Overriding superclass methods Working with superclasses that.
CSE 115 Week 10 March , Announcements March 21 – Lab 7 Q & A in lecture March 21 – Lab 7 Q & A in lecture March 26 – Exam 7 March 26 – Exam.
Lecture 10: Inheritance Subclasses and superclasses The inheritance chain Access control The Object cosmic superclass The super keyword Overriding methods.
Advanced Object-Oriented Programming Features
Inheritance Review/Recap. ClassA extends ClassB ClassA now inherits (can access and use) all public and protected elements of ClassB We can expect the.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Vocabulary Key Terms polymorphism - Selecting a method among many methods that have the same name. subclass - A class that inherits variables and methods.
CS 1110 Final Exam: Review Session 2 Part 1 : Inheriting classes 1. Inheritance Facts 2. Constructors in Subclasses BREAK : 10 sec. Part 2 : Working with.
PHP Workshop ‹#› PHP Classes and Object Orientation.
(c) University of Washington04-1 CSC 143 Java Inheritance Example (Review)
Inheritance using Java
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Intro to OOP with Java, C. Thomas Wu
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
ClassesPHPMay-2007 : [‹#›] PHP Classes and Object Orientation.
Inheritance Building one object from another. Background Object-oriented programming is normally described has offering three capabilities Encapsulation:
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
These materials where developed by Martin Schray. Please feel free to use and modify them for non-commercial purposes. If you find them useful or would.
Inheritance Chapter 10 Programs built from objects/instances of classes An O.O. approach – build on earlier work. Use classes in library and ones you have.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)OO PHP PHP Classes and Object Orientation.
Inheritance (Part 2) KomondorBloodHound PureBreedMix Dog Object.
Creating Elements with Ext.DomHelper By Aaron Conran.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Chapter 7: Class Inheritance F Superclasses and Subclasses F Keywords: super and this F Overriding methods F The Object Class F Modifiers: protected, final.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Encapsulation, Inheritance, Composition. Class Methods Can be either void or return Can have parameters or not Must be static Should be public Know how.
OOP: Inheritance. Inheritance A class can extend another class, inheriting all its data members and methods while redefining some of them and/or adding.
Inherited Classes in Java CSCI 392 Ch 6 in O’Reilly Adapted from Dannelly.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Prototype Chain and Inheritance Prototype chain, Inheritance, Accessing Base Members Software University Technical Trainers SoftUni Team.
1 / 71 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 4 Programming Fundamentals using Java 1.
ExtJS Ext.util.Observable By Aaron Conran. Observer Design Pattern An observable object can notify any number of observers who would like to know when.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 20 – C++ Subclasses and Inheritance.
Advance ExtJS concepts. Javascript Object var obj = {}; obj.x = 10; obj.y = 20; var obj = new Object; obj.x = 10; obj.y = 20; function Foo() {this.x =
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
Advance ExtJS concepts. Javascript Object var obj = {}; obj.x = 10; obj.y = 20; var obj = new Object; obj.x = 10; obj.y = 20; function Foo() {this.x =
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Interface, Subclass, and Abstract Class Review
Week 4 Object-Oriented Programming (1): Inheritance
Lecture 10: Inheritance Subclasses and superclasses
البرمجة بلغة الفيجول بيسك ستوديو
MSIS 670 Object-Oriented Software Engineering
Inherited Classes in Java
CSE 1030: Implementing GUI Mark Shtern.
Java – Inheritance.
Chapter 11 Inheritance and Polymorphism
Java Programming, Second Edition
Inheritance CT1513.
Chapter 10: Method Overriding and method Overloading
Method Overriding and method Overloading
Object-Oriented PHP (1)
Classes and Objects Imran Rashid CTO at ManiWeber Technologies.
Inheritance Lakshmish Ramaswamy.
Presentation transcript:

ExtJS Classes By Aaron Conran

Creating Classes Creating classes in JavaScript is easy as creating a constructor function and using the new keyword when creating an instance of that class. Person Class: var Person = function(config) { Ext.apply(this, config); }; Using the Person class: var me = new Person({fName: ‘Aaron’,lName: ‘Conran’, dob: ’03/23/1984’});

Ext.apply Ext.apply copies all attributes of one object to another. Ext.apply is often used at the beginning of constructors to copy configuration arguments to the this scope. The new keyword creates a new blank object in the scope of this. You can also supply a 3 rd argument as a default configuration. Ex: Ext.apply(this, config); // with defaults var defConfig = {test: ‘abc’}; Ext.apply(this, config, defConfig);

Ext.applyIf Ext.applyIf works similarly to Ext.apply except if properties already exist they won’t be overwritten. Ex: var point = point || {}; var default = {x: 0, y: 0}; Ext.applyIf(point, default);

Ext.extend Ext.extend is used to extend or inherit from classes which already exist. Generic Pattern: var SubClass = function() { SubClass.superclass.constructor.call(this); }; Ext.extend(SubClass, BaseClass, { newMethod : function() {}, overriddenMethod : function() {} }; SubClass extends BaseClass and overrides overridenMethod and adds newMethod.

superclass.constructor The superclass.constructor property points to our base (or super) class constructor. We use the JavaScript call method to run the constructor in the scope of this. this will always be our first argument of call. Other arguments will be passed to our base constructor: Ex: BaseClass.superclass.constructor.call(this, config);

Extending an Ext Class Extending and Customizing Ext classes is easy Goal: Create a extension of BasicDialog –New class DefaultDialog which extends from BasicDialog –Provide a set of defaults for dialogs modal, width, height, shadow, draggable, etc –No need to add/override methods to BasicDialog

Extending an Ext class var DefaultDialog = function(config) { var config = config || {}; // default config to blank object var defConfig = {title: 'Default', // provide a default config height: 130, width: 250, shadow: true, modal: true, draggable:true, fixedcenter:true, collapsible: false, closable: true, resizable:false}; Ext.applyIf(config, defConfig); // apply defConfig IF config does not have property var el = Ext.DomHelper.append(document.body, {tag: 'div'}); // create el DefaultDialog.superclass.constructor.call(this, el, config); // run superclass }; Ext.extend(DefaultDialog, Ext.BasicDialog); // DefaultDialog extends Ext.BasicDialog

DefaultDialog example We can now re-use the DefaultDialog class By passing configuration options we can override the defaults By omitting the configuration, we assume the defaults dlg = new DefaultDialog({title: 'First Dialog', width: 300}); dlg.show(); dlg2 = new DefaultDialog(); dlg2.show();