1

I am using a wrapper class so as not to have a glut of aura:attributes (this may be the problem in and of itself). I have a previous lightning component that has about 16 attributes and passing them all through as method parameters was messing (there is probably a better way of doing that). Here is a more basic example:

WRAPPER CLASS

public class CreditAppWrapper {
    @AuraEnabled Credit_Application__c creditApp {get;set;}
    @AuraEnabled Business__c business {get;set;}
    @AuraEnabled Vehicle__c equipment {get;set;}
    @AuraEnabled List<Applicant__c> principals {get;set;}
}

COMPONENT

 <aura:attribute name="cApp" type="CreditAppWrapper"/>
...
<lightning:input type="String" label="NAME" value ="{!v.cApp.Business.Name}"/>  

JS CONTROLLER

console.log(component.get("v.cApp.Business.Name"));

This logs null as the value

Is this because I can't have multiple levels on the input (ie. cApp & Business & Name)? Do I need to instantiate the wrapper class first?

1 Answer 1

3

I'm new to lightning, but two things I see:

  • The type name in your component isn't matching the class name: 'AppWrapper' versus 'CreditAppWrapper'
  • The properties you are exposing aren't primitive types, so yes, they'd need to instantiated.
2
  • Thanks Corey. Yeah, the "AppWrapper" vs "CreditAppWrapper" was a typo when entering it. I figured the instantiating was the issue, but whenever I try to use the default attribute, it breaks a lot of things. Perhpas I will try from my init function.
    – awh01
    Commented Feb 26, 2019 at 17:45
  • Yeah, just instantiating it within my init function did the trick. Thank you, Corey
    – awh01
    Commented Feb 26, 2019 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .