1
public virtual class TopLevel {

    @AuraEnabled
    public virtual void getwriter() {
        System.debug('At top level');
    }

    public class lowerLevel extends TopLevel {

        @AuraEnabled
        public override void getwriter() {
            System.debug('Within lowerLevel.writer.');
        }
}

I'm trying to call lowerLevel from within my javascript code as such

var action = component.get('c.lowerLevel.writer');
action.setCallback(this, function(ret) {});
$A.enqueueAction(action);

But I'm getting the error of

Uncaught Unknown controller action 'lowerLevel.writer'

It makes sense to me that it should work since the TopLevel is implied (as we can call

var action = component.get('c.writer');

and in the system debug we'll find "At top level"

My lightning component is defined as such

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="TopLevel">

Anyone know how I can make it do what I want?

Adrian Larson
  • 149,971
  • 38
  • 239
  • 420
IanQ
  • 237
  • 2
  • 13
  • I'm pretty sure this isn't actually "allowed", despite the compiler allowing the annotation. – sfdcfox Sep 26 '17 at 17:43
  • Can you point me in the right direction to doing what I want then? – IanQ Sep 26 '17 at 17:58
  • Isn't this a case of https://salesforce.stackexchange.com/questions/123744/calling-apex-from-lightning-returning-a-class-extending-an-abstract-class ? – Christian Szandor Knapp Sep 26 '17 at 19:23
  • Seems like it. Also, silly question but if I create a subclass should it go into the same file as the main class or in a new file? Or will it not make a difference? – IanQ Sep 26 '17 at 19:37

0 Answers0