I have a set of ids called oppIdsInWrapper inner class. However while I build my wrapper, this is always null and empty. I want be able to reference this as I build my records to avoid duplicate ids. However it's as if this is re-created everytime I add to my wrapOppList.
If I place my Set at the upper class level and instantiate it in my controller, the inner class and wrapper do not recognize it:
"Variable does not exist: oppIdsInWrapper"
What am I doing wrong? Do I have really have to perform this logic before I build my wrapper here? :
wrapOppList.add(new wrapOpportunity(a, a.Apttus__Related_Opportunity__r.Opportunity__c));
Main Controller:
public class AgreementWithOppsController2 {
public list<wrapOpportunity> wrapOppList { get; set; }
public AgreementWithOppsController() {
...
wrapOppList.add(new wrapOpportunity(a, a.Apttus__Related_Opportunity__r.Opportunity__c));
}
Wrapper:
public class wrapOpportunity{
public Apttus__APTS_Agreement__c agreement{get;set;}
public Boolean isSelected{get;set;}
public Boolean isDisplayed{get;set;}
public Set<Id> oppIdsInWrapper {get;set;}
public wrapOpportunity(Apttus__APTS_Agreement__c a, String oppNumber){
agreement=a;
if(oppIdsInWrapper==null){
oppIdsInWrapper = new Set<Id>();
system.debug('expected to hit only one time?'); //this hits every time, why? where can i store this and access it?
}
system.debug('id wrapper size: '+oppIdsInWrapper.size());
if(!oppIdsInWrapper.contains(a.Apttus__Related_Opportunity__r.Id)){
oppIdsInWrapper.add(a.Apttus__Related_Opportunity__r.Id);
isDisplayed = true;
}
else{
isDisplayed = false; //this never hits, why?
system.debug('does this hit?');
}
isSelected = false;
}
}