function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
A MeA Me 

How to read map inside wrapper class

Hi,

I have a lightning component controller that makes call to apex controller in the init handler
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
The function calls an apex controller method which returns a wrapper class(say CustomWrapperClass):
CustomWrapperClass{
public <Date,String> map1{get; set;}
public <Date,String> map2{get; set;}
public String str1 {get; set;}
}

The component has these attributes defined
The client side controller has wrapper attribute defined 
<aura:attribute name="mywrapper" type="CustomWrapperClass" />
<aura:attribute name="myMap" type="Map" />

Here is the handler code
doInit : function(component, event, helper) {
        var queryAction = component.get("c.getWrappedResults"); //apex method name getWrappedResults
       queryAction.setCallback(this, function(response) {
       var wrapper = response.getReturnValue();
      if (paymentWrapper == null)
                return;
     //Code to assign the wrapper's map variables to component's attribute Map1
    });
     $A.enqueueAction(queryAction);
    } 

How to assign the custom wrapper class's map member (Map1) to MyMap attribute of the component and then also output its key value pairs on the component?
Can we somehow use wrapper.map1 ?



Regards,
A M    
rajat Maheshwari 6rajat Maheshwari 6

Hi A M,

Please follow this link, It would help you definately 

https://balkishankachawa.wordpress.com/2015/10/31/referencing-apex-map-in-lightning-component/

 

Mark as best answer, If it make sense :)

Thanks
Rajat maheshwari
rajatzmaheshwari@gmail.com