How to use @AuraEnabled base class method in Lightning Component?
Why can't our Lightning component see our base method in the base class, but can see it when it's copied in the extending class?
Going through the documentation, it seems that all @AuraEnabled
methods used from JS Controller in an Aura Component need to be explicitly annotated in the Class (emphasis mine).
Only methods that you have explicitly annotated with
@AuraEnabled
are exposed.
While Static methods defined in parent class can be invoked from a child class even if not defined in the child itself, but in case of Lighting Aura/Web Components, even though it's not very well documented for scenarios like inheritance, based on what documentation says, you will need to ensure that the annotated method is explicitly available in the Controller class. So if in your component you have a AwesomeController
declared as a Controller, the method you are trying to invoke should be available in that class itself.
In your scenario, if you want to refactor the code, you can achieve it by using something as below. You don't follow inheritance here but at least this way you will be still able to consolidate your common code at one place and be able to utilize it.
public class AwesomeController {
@AuraEnabled
public static List<SelectOption> getGenderPicklistEntries() {
return CommunityControllerBase.getGenderPicklistEntries()
}
}