You need to sign in to do that
Don't have an account?
d.tejdeep@nicomatic.in
how can set wrapper class values to ui:inputtext lightning ?
Controller :
I want to set wrapper values to the UI: input how can do it
component.set("v.partnumber", PartNicomat);
component.set("v.PartDescription",PartDescription);
component.set("v.PartStock",PartStock)
Thanks in advance
public class quotewebservices { public static String language {get;set;} Public static string NicoPinFrance{get;set;} public static List<AccountDetails> AccountDetailsList {get;set;} @AuraEnabled public static List<AccountDetails> france(string NicoPinFrance){ // public static List<AccountDetails> InfoWithoutAccNum() { String XMLString; AccountDetailsList = new List<AccountDetails>(); XMLString='<RESULT><PARTNUMBER>D221C04DXX-0005-3310</PARTNUMBER><DESCRIPTION>Boîtier série\'s 0F 12 pts</DESCRIPTION><DESCRIPTIONUK>housing serie\'s OF 12pts</DESCRIPTIONUK><STOCK>43382</STOCK><CLIENTPNS></CLIENTPNS></RESULT>'; String PartNicomat=''; String PartDescription= ''; String PartDescriptionUK=''; String PartStock=''; String PartClientPNREF=''; //Getting the values from xml String system.debug(XMLString); if(XMLString!=null){ Dom.Document doc = new Dom.Document(); doc.load(XMLString); dom.XmlNode node=doc.getRootElement(); //Condition to check the responce without error if(node.getChildElements()[0].getName() != 'ERROR'){ PartNicomat=node.getChildElement('PARTNUMBER',null).getText(); PartDescription= node.getChildElement('DESCRIPTION',null).getText(); PartDescriptionUK=node.getChildElement('DESCRIPTIONUK',null).getText(); PartStock= node.getChildElement('STOCK',null).getText(); //Iterating the child elements for(dom.XmlNode child:node.getChildElements()){ if(child.getName() =='CLIENTPNS'){ //iterating the grand child elements for(dom.XmlNode gchild:child.getChildElements()){ if(gchild .getName() == 'CLIENTPN'){ //Iterating the grand grand child elements for(dom.XmlNode ggchild:gchild.getChildElements()){ if(ggchild .getName() == 'CLIENTPNREF'){ PartClientPNREF=ggchild.getText(); } }//End of for loop }//End of if }//End of for loop }//End of if }//End of for loop }//End of if condition if(PartDescription!=null){ if(PartDescription.contains('\'')){ PartDescription=PartDescription.replace('\'','\\\''); } } if(PartDescriptionUK!=null){ if(PartDescriptionUK.contains('\'')){ PartDescriptionUK=PartDescriptionUK.replace('\'','\\\''); } } system.debug(PartNicomat+PartDescription); AccountDetails acc = new AccountDetails(); acc.PartNicomat= PartNicomat ; acc.PartDescription = PartDescription; acc.PartDescriptionUK=PartDescriptionUK; acc.PartStock=PartStock; acc.PartClientPNREF=PartClientPNREF; AccountDetailsList.add(acc); }//End of if system.debug(AccountDetailsList); return AccountDetailsList ; }//End of method public class AccountDetails{ @AuraEnabled public String PartNicomat{get;set;} @AuraEnabled public String PartDescription{get;set;} @AuraEnabled public String PartDescriptionUK{get;set;} @AuraEnabled public String PartStock{get;set;} @AuraEnabled public String PartClientPNREF{get;set;} } }component :
<aura:component controller="quotewebservices"> <aura:attribute name="AccountDetails" type="object"/> <aura:attribute name="firstName" type="String" default="D221C04DXX-0005-3310"/> <aura:attribute name="partnumber" type="string" default=""/> <aura:attribute name="PartDescription" type="string" default=""/> <aura:attribute name="PartStock" type="string" default=""/> <lightning:input label="firstName" name="Noofqli" value="{!v.firstName}" /> <ui:inputtext value="{!v.partnumber}" label="Part number"/> <ui:inputtext value="{!v.PartDescription}" label="Part Description"/> <ui:inputtext value="{!v.PartStock}" label="PartStock"/> <ui:button label="Call server" press="{!c.echo}"/> </aura:component>JS
({ "echo" : function(cmp) { var firstName = cmp.get("v.firstName"); var action = cmp.get("c.france"); action.setParams({ NicoPinFrance : firstName }); action.setCallback(this, function(response) { var state = response.getState(); if ( state === "SUCCESS") { cmp.set('v.AccountDetails', response.getReturnValue()); var acc= cmp.get("v.AccountDetails"); alert(acc.PartNicomat); // alert("From server: " + response.getReturnValue()); // component.set("v.partnumber", PartNicomat); // component.set("v.PartDescription",PartDescription); // component.set("v.PartStock",PartStock) } else if (state === "INCOMPLETE") { // do something } else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(action); } })
I want to set wrapper values to the UI: input how can do it
component.set("v.partnumber", PartNicomat);
component.set("v.PartDescription",PartDescription);
component.set("v.PartStock",PartStock)
Thanks in advance
Try something like above