I don't know if you understood what I said, but take a look on this example:
public class Main {
public static class A {
public void methodA() {
System.out.println("A.methodA()");
}
public void methodB() {
methodA();
System.out.println("A.methodB()");
}
}
public static class B extends A {
public void methodA() {
System.out.println("B.methodA()");
}
public void methodB() {
System.out.println("B.methodB()");
super.methodB();
}
}
public static void main(String[] args) {
B b = new B();
b.methodB();
}
}
The output will be:
B.methodB()
B.methodA()
A.methodB()
The implementation that I did in the javascript library works exactly like this.
On Sat, Apr 25, 2009 at 4:58 AM, Johan Compagner <[email protected]> wrote:
> Java doesnt work like that
> If you are in X and you call super.Y() then you will skipp the Y of
> that class but really go to a super impl.
>
> You seem to have implemented it in js with _super exactly like we do
> also in our product Servoy, only there the 'classes' are not js
> things but Forms (UI elements) that has a set of js functions
>
> On 25/04/2009, Eduardo Nunes <[email protected]> wrote:
>> Yes sure, you can call any method with super, but the syntax is
>> "this._super().method()".
>>
>> If you are in the "someFunction()" method and you call
>> "this._super().someFunction()" it will call the next "someFunction"
>> method up in the class hierarchy, but if you are in the
>> "someFunction()" method and call "this._super().anotherFunction()" it
>> will call the latest implementation of "anotherFunction" method. It
>> works exactly as Java.
>>
>> On Fri, Apr 24, 2009 at 8:44 PM, Jeremy Thomerson
>> <[email protected]> wrote:
>>> Does it only apply to attributes then? Can you still call the super's
>>> functions? How do I do this?
>>>
>>> function someFunction() {
>>> addMoreFunctionality();
>>> super.someFunction();
>>> }
>>>
>>> --
>>> Jeremy Thomerson
>>> http://www.wickettraining.com
>>>
>>>
>>>
>>>
>>> On Fri, Apr 24, 2009 at 6:37 PM, Eduardo Nunes <[email protected]> wrote:
>>>> uhmm, why do you think it is pretty big? I shouldn't use
>>>> super.attribute, you can use this.attribute instead.
>>>> For example:
>>>>
>>>> var Shape = Class.extend({
>>>> height: 0,
>>>> width: 0,
>>>> init: function(height, width) {
>>>> this.height = height;
>>>> this.width = width;
>>>> },
>>>> info: function() {
>>>> alert("I have height = " + this.height +
>>>> " and width = " + this.width);
>>>> }
>>>> });
>>>>
>>>> var Rectangle = Shape.extend({
>>>> info: function() {
>>>> alert("I'm a rectangle and I have height = " + this.height + " and
>>>> width = " + this.width);
>>>> // you can't do this.super().height, because this makes the method
>>>> accessor counter gets lost.
>>>> }
>>>> });
>>>>
>>>> All attributes from the super class are copied to the new class.
>>>>
>>>> On Fri, Apr 24, 2009 at 8:07 PM, Jeremy Thomerson
>>>> <[email protected]> wrote:
>>>>> Looks nice, but:
>>>>>
>>>>>> Limitations
>>>>>>
>>>>>> It's not possible to access an attribute through the super function.
>>>>>
>>>>> That seems pretty big. Do you plan on adding that?
>>>>>
>>>>> --
>>>>> Jeremy Thomerson
>>>>> http://www.wickettraining.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Apr 24, 2009 at 5:47 PM, Eduardo Nunes <[email protected]>
>>>>> wrote:
>>>>>> Hello guys,
>>>>>>
>>>>>> I'm not used to develop in Javascript but, as a fan of programming
>>>>>> languages and object-oriented paradigm, my friend Otavio Avila and I
>>>>>> decided to develop a kind of inheritance in JavaScript. He is a very
>>>>>> experienced javascript developer and html coder, with helped me a lot
>>>>>> with my lack of knowledge in these areas. You can check more about it
>>>>>> in http://jsii.googlecode.com. The project is licensed in LGPL that
>>>>>> enables you to use it in your commercial, or not, applications.
>>>>>> I think it could help to make more complex things with javascript.
>>>>>>
>>>>>> Thanks,
>>>>>> Eduardo S. Nunes
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>> For additional commands, e-mail: [email protected]
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [email protected]
>>>>> For additional commands, e-mail: [email protected]
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]