You need to sign in to do that
Don't have an account?
Quddus Ololade 4
Unable to use my wrapper class in Lightning component API version 42
Below Code:
Component Code:
This is speacially on the lightning component API 42 version, I have old component which is on 40 API version works absolutely fine.
Is this is a bug or not the right way to use wrapper any more in lightning ?
Any ideas appreciated !
Thanks
public class parentclass{ public class Model{ @AuraEnabled public String year {get;set;} @AuraEnabled public Map<Integer, Decimal> dataMap {get;set;} } }
Component Code:
<aura:component controller="parentclass" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global"> <aura:attribute name="listVehicles" type="parentclass.Model[]" />Error: while saving the component: Failed to save undefined: Invalid <aura:attribute> type: Model
This is speacially on the lightning component API 42 version, I have old component which is on 40 API version works absolutely fine.
Is this is a bug or not the right way to use wrapper any more in lightning ?
Any ideas appreciated !
Thanks
I worked on your code review it
demo.app ModelClass .cmp
ModelClassController.js
ModelClass.apxc
view
working well in my dev org.
All Answers
You cannot use inherited class attribute type
instead of this you can use
Let me know, is it work for you.
Pass values in JSON format and deserialize it in JS Controller
Thanks,
Gaurav
Skype: gaurav62990
I can understand that Wrapper isn't working in your case "42.0" version, but we can still implement MAP and List in the same class. Can you check the below link and try to convert your JS controller to get the job done.
https://salesforce.stackexchange.com/questions/140608/how-to-iterate-over-map-in-salesforce-lightning-component/140630
Thanks,
Gaurav
Skype: gaurav62990
check out below post :
http://sfdcmonkey.com/2017/07/06/use-wrapper-class-lightning-component/
there are 2 solution for your problem :
1. create your inner/wrapper class as a new class. (cut your wrapper class code from main class and create a new parent level class with wrapper class code and then in your aura:attribute you can directly use parent level wrapper class as attribute type).
2. don't touch apex code, just update aura :attribute type as object type : i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you
thanks
sfdcmonkey.com
I worked on your code review it
demo.app ModelClass .cmp
ModelClassController.js
ModelClass.apxc
view
working well in my dev org.
Thanks !