This is my wrapper class:
public class WrapperCriteria
{
@AuraEnabled
public Criteria_Master__c criteriaMaster {get;set;}
@AuraEnabled
public Integer index {get;set;}
@AuraEnabled
public Action_Criteria__c record {get;set;}
@AuraEnabled
public string CriteriaMasId {get;set;}
@AuraEnabled
public String ObjectApiNAme {get;set;}
@AuraEnabled
public Criteria_Master__c CriteriaMas{get;set;}
@AuraEnabled
public String SpecialOperator {get;set;}
@AuraEnabled
public String SelObjectName {get;set;}
@AuraEnabled
public String FieldName{get;set;}
@AuraEnabled
public String Operator{get;set;}
@AuraEnabled
public decimal specialOperatorSlashValue{get;set;}
@AuraEnabled
public decimal specialOperatorValue{get; set;}
@AuraEnabled
public List<SelectOption> ComponentsInWpr{get; set;}
public WrapperCriteria()
{
this.criteriaMaster=new Criteria_Master__c();
this.Components=new List<SelectOption>();
this.Components1=new List<SelectOption>();
}
}
I have a method:
@AuraEnabled
public static WrapperCriteria getComponent(string wrapval,string id) {
String objectName;
Criteria_Master__c cmas = new Criteria_Master__c();
List < WrapperCriteria > warpList = (List < WrapperCriteria > ) JSON.deserialize(wrapval, List<WrapperCriteria >.class);
system.debug('::::::wrList value::::' + warpList);
system.debug('id value ::::::' + id);
WrapperCriteria ac=new WrapperCriteria ();
List < SelectOption > ObjNames = new List < SelectOption > ();
ObjNames.add(new SelectOption('', '--None--'));
ObjNames.add(new selectoption('Pay_Element_Master__c', 'Pay Element'));
ObjNames.add(new selectoption('CTC_Master__c', 'CTC Master'));
Map <String,String> ctcMasAPINames = new Map < String, String > ();
List < SelectOption > Components;
List < SelectOption > Components1;
//Criteria_Master__c cmas = new Criteria_Master__c(); //write a class
cmas = [select id, Name, Action_Criteria__c, Company_Master__c from Criteria_Master__c where Id=:id];
if (warpList.size() > 0) {
for (WrapperCriteria wr: warpList) {
List <SelectOption > options = new List <SelectOption > ();
if (wr.ObjectApiNAme == 'Pay_Element_Master__c') {
for (SelectOption so: ObjNames) {
if (so.getValue() == wr.ObjectApiNAme) {
objectName = so.getLabel();
system.debug('****objectname *****' + objectName);
}
}
wr.SelObjectName = objectName; //aassigned to wrapper
for (Pay_Element_Master__c pem: [select id, name, Company_Master__c from Pay_Element_Master__c where Company_Master__c = : cmas.Company_Master__c]) {
options.add(new SelectOption(pem.id, pem.name));
ctcMasAPINames.put(pem.id, pem.name);
System.debug('--------Pay element MAster MAP VAlues-----' + ctcMasAPINames);
}
Components = options;
system.debug('components value ::::::'+ac.Components);
}
else if (wr.ObjectApiNAme == 'CTC_Master__c') {
for (SelectOption so: ObjNames) {
if (so.getValue() == wr.ObjectApiNAme) {
objectName = so.getLabel();
system.debug('-----------objectname --------------' + objectName);
}
}
wr.SelObjectName = objectName;
Map < String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();
Schema.sObjectType objType = globalDescription.get('CTC_Master__c');
Schema.DescribeSObjectResult ob = objType.getDescribe();
if (ob == Null) {
AuraHandledException e = new AuraHandledException('Invalid sObject Type');
e.setMessage('Invalid sObject Type');
system.debug(e);
throw e;
}
Map < String, Schema.SObjectField > mapFieldList = ob.fields.getMap();
for (Schema.SObjectField field: mapFieldList.values()) {
Schema.DescribeFieldResult fieldResult = field.getDescribe();
if (fieldResult.isAccessible() && (fieldResult.getType() == Schema.DisplayType.Integer || fieldResult.getType() == Schema.DisplayType.Double || fieldResult.getType() == Schema.DisplayType.Currency)) {
options.add(new SelectOption(fieldResult.getName(), fieldResult.getLabel()));
ctcMasAPINames.put(fieldResult.getName(),fieldResult.getLabel());
}
}
Components1= options;
}
}
}
return null; //Instead of null I want to return components and components1 to Lightning component page
}
I have couple of questions:
1.Instead of null I want to return components and components1 value to Lightning component page [As per my understanding using one method we can return only one value].How to do that?
2.I cant write return type as List selectOption why beacuse it isnt working in lightning.But in this scenario How to do this.[I need option values because i want to display that values in aura:component. If its vf page means we can easily access like this {!components}...But in Lightning how to do this....
3.How to display components & components1 value in within Lightning select option tag?