0

I am storing values in wrapper from UI input: Component is like (on press of submit button, calling Controller)

<aura:component controller="AccountCreationFormClass" implements="force:appHostable>
<aura:attribute name="AccountWrapper" type="CommonWrapperClass.AccountCreationWrapperClass"/>
<ui:inputText value="{!v.AccountWrapper.Name}" />
<ui:button label="Submit" press="{!c.Submit}"/>

Wrapper class is like

public class CommonWrapperClass{
    public class AccountCreationWrapperClass{
@AuraEnabled public String Name {get;set;}
public AccountCreationWrapperClass(){
            Name = '';
  } 
 }
}

Component is like (showing only submit part)

Submit : function(component, event, helper){
        var objAccount = component.get("v.AccountWrapper");
        console.log("Individual Values: " + objAccount.Name);  // Values are shown    
        console.log("Value of ObjAccount1: " + JSON.stringify(component.get("v.AccountWrapper"))); // Values not shown
        console.log("Value of ObjAccount2: " + JSON.stringify(objAccount)); // Values not shown
        console.log("Value of ObjAccount3: " + objAccount);   // Values not shown
    }

When I am trying to see values from individual component of the wrapper (where ever: // Values are shown comment), its showing user entered values but values are not showing up from wrapper (where ever: // Values not shown comment)

Here is my doInit where I am assigning default values

doInit : function(component, event, helper){        
        var tempArray = [];
        tempArray.push
        ({
            "SYField":"",
            "AccountNumber":"",
            "Name":"ABC",
            "Type":"",
            "Industry":"",
            "Sic":"",
            "Active":false,
            "NumberOfEmployees":0,
            "AccountPriority":"",
            "SalesYear":""
        });
        component.set("v.AccountWrapper",tempArray);     

    }
1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Adrian Larson
    Commented Nov 29, 2017 at 14:14

1 Answer 1

0

Attribute "AccountWrapper" is not of type list. And you are assigning Array to this variable. Try using this.

var a = new Object(); 
a.name = 'Test'; 
// All the fields ; 
component.set("v.AccountWrapper",a);

You must log in to answer this question.

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